diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/auth_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/auth_test.go index 8fc2f233d7a7dd71a0d08c21ffd115645df8e061..b22d9ced6a77a400755c687a7e87cdaf2b9d4d5d 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/auth_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/auth_test.go @@ -10,7 +10,7 @@ import ( "net/http/httptest" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func TestBasicAuth(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/binding_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/binding_test.go index 8c25afd980a9f9ac36e0b9e65d9a4cf8285d5c5b..db1678e425527c726f1be3aba0d379f059aec9f7 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/binding_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/binding_test.go @@ -9,7 +9,7 @@ import ( "net/http" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) type FooStruct struct { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/default_validator.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/default_validator.go index d5a6f2e99f223aa316109ee610bdf3191a82e9f5..7f12152b0989c55d9cb09b652a2fe86fb7edf7db 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/default_validator.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/default_validator.go @@ -4,7 +4,7 @@ import ( "reflect" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/gopkg.in/bluesuncorp/validator.v5" + "gopkg.in/bluesuncorp/validator.v5" ) type defaultValidator struct { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/validate_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/validate_test.go index 8ab0bc5246ace0820bcacb3b6a5d5763124b38c6..27ba7b6671d5fc9ebd7dc8fe80a5c58b4c5adb62 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/validate_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/binding/validate_test.go @@ -7,7 +7,7 @@ package binding import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) type struct1 struct { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/context.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/context.go index a5e946ccc5655dc498b5866c0da8cc2fb1b34f49..f5f0de4a8a7fd60c60063d3776a44bc88f336947 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/context.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/context.go @@ -12,10 +12,10 @@ import ( "strings" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin/binding" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin/render" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/manucorporat/sse" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/net/context" + "github.com/gin-gonic/gin/binding" + "github.com/gin-gonic/gin/render" + "github.com/manucorporat/sse" + "golang.org/x/net/context" ) const ( diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/context_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/context_test.go index 9e9f3dda4b8ea983c96fd42c1b3ff4a302d07414..a638d6ddcb105c1e3853bcef867cc9c9a607d3cb 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/context_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/context_test.go @@ -14,8 +14,8 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/manucorporat/sse" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/manucorporat/sse" + "github.com/stretchr/testify/assert" ) // Unit tests TODO diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/debug_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/debug_test.go index ea5896167769f444debeba3e88e60675f641c5a6..425aff0fe7f64b855455fda54fde40bfecd0f2bc 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/debug_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/debug_test.go @@ -12,7 +12,7 @@ import ( "os" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) // TODO diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/errors_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/errors_test.go index aa7cc3ddc05bbc39c8ea1bf13c4d56e2ef11a39c..748e3fe059f116de02e8d0b394b2bbe314fc5292 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/errors_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/errors_test.go @@ -9,7 +9,7 @@ import ( "errors" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func TestError(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go index 2b09841028313a030a5c24a97c57f03635043209..a5e1796237e607f0a5825c05a8e909b528e3d8a2 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/app-engine/hello.go @@ -1,7 +1,7 @@ package hello import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" "net/http" ) diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/basic/main.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/basic/main.go index b0f1ece7c982d576e76f754f8d8a66390d941c68..80f2bd3c7f3ff8773433af41441e23c611589784 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/basic/main.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/basic/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ) var DB = make(map[string]string) diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go index 538cea7456dc31e663483a32d11a54c27926863c..1f3c8585ff9032a8f326f365bd0528b83f60dfa4 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/main.go @@ -4,7 +4,7 @@ import ( "fmt" "runtime" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ) func main() { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go index cc7c008794caa87208dac752f38f5d9bed2ce1d5..b187756580b8c699a5695e29fc90653c3dcba31a 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-advanced/routes.go @@ -7,7 +7,7 @@ import ( "strings" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ) func rateLimit(c *gin.Context) { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go index 8f7f473fd3bb6454b3e1bb5e8f3b1aea3ef48455..e4b55a0f094380343cbac19cf68f1bdf066a3409 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/examples/realtime-chat/main.go @@ -5,7 +5,7 @@ import ( "io" "math/rand" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ) func main() { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/gin.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/gin.go index 05369c61ff77f7fbccadf5036bf30dad69de5be8..e18d5b6da3f349a343314ac7345a9ae326cb3f69 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/gin.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/gin.go @@ -11,7 +11,7 @@ import ( "os" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin/render" + "github.com/gin-gonic/gin/render" ) const Version = "v1.0rc2" diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_integration_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_integration_test.go index fe2fe754249a0cf4762696477f67ca7b8467582a..f7ae0758e08892803d3eee5353b01266e3939cdc 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_integration_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_integration_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func TestRun(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_test.go index 96cbf572c31260b1880cf28b1daab1ef9991ddeb..fc9e821233d5de654c3b8fdf9b2d08161f7a7211 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/gin_test.go @@ -8,7 +8,7 @@ import ( "reflect" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) //TODO diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/githubapi_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/githubapi_test.go index fe2328246665397d8cbb28ec0547c708a78e3919..2227fa6ae8fcf61d919a02873f095bc58048d168 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/githubapi_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/githubapi_test.go @@ -12,7 +12,7 @@ import ( "net/http/httptest" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) type route struct { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/logger_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/logger_test.go index 1d4755ec79903e774e1d0b452af8659174ef02be..1cdaa94cb5d31f220c6e08cd694256a88980e509 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/logger_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/logger_test.go @@ -8,7 +8,7 @@ import ( "bytes" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) //TODO diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/middleware_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/middleware_test.go index 8af80d333d5b88142131abf6673c550775adc7f6..7876c7ef493c41bef2d6b8759ad5decd2b820a6b 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/middleware_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/middleware_test.go @@ -9,8 +9,8 @@ import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/manucorporat/sse" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/manucorporat/sse" + "github.com/stretchr/testify/assert" ) func TestMiddlewareGeneralCase(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/mode.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/mode.go index 5dcf4e85a2385fdbf6c4f5f61af2485236b84b5b..15efaeb872d9127b592b0662b2e890c5720a0db3 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/mode.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/mode.go @@ -8,8 +8,8 @@ import ( "io" "os" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin/binding" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/mattn/go-colorable" + "github.com/gin-gonic/gin/binding" + "github.com/mattn/go-colorable" ) const ENV_GIN_MODE = "GIN_MODE" diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/mode_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/mode_test.go index 8fd7a43b898cfef11a209e6243422396179b1ef1..2a23d85e94f5171e4ee9c5d91f374e705ff4b421 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/mode_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/mode_test.go @@ -7,7 +7,7 @@ package gin import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func init() { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/path_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/path_test.go index 16eb439bdd50fb674223d60479f1e83a4603a5ab..01cb758a4f517a2523f7d06718a8ce7a809944f8 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/path_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/path_test.go @@ -9,7 +9,7 @@ import ( "runtime" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) var cleanTests = []struct { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/recovery_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/recovery_test.go index aae0ef2c0097207d09e7f74ed1533bb7db8f1b9d..39e71e816023b0efee4a8e766f957d526e77203a 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/recovery_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/recovery_test.go @@ -8,7 +8,7 @@ import ( "bytes" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) // TestPanicInHandler assert that panic has been recovered. diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/render/render_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/render/render_test.go index 8be5220ca911c79cf95020d891d729301653b2ed..7a6ffb7d5cf28d353cf6b98e9b09d6f552a45236 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/render/render_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/render/render_test.go @@ -10,7 +10,7 @@ import ( "net/http/httptest" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) // TODO unit tests diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/response_writer_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/response_writer_test.go index ec7133a80d58d24b2cb6176fe610315bf3c139d3..7306d192573c53891b53bde3c6fd1f17cdd5662b 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/response_writer_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/response_writer_test.go @@ -9,7 +9,7 @@ import ( "net/http/httptest" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) // TODO diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/routergroup_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/routergroup_test.go index 67f7f8e60e9d8ff8425ace26d93d49f60bc3eb81..14c7421bd350aa4c56292af88b41024acb33db35 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/routergroup_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/routergroup_test.go @@ -7,7 +7,7 @@ package gin import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func init() { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/routes_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/routes_test.go index 3f5d23ed4a05dfd05d7c5fd1d76f4490276b9611..2f451f84eb0bc4ad96eb9029bc1585d95a81c0f6 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/routes_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/routes_test.go @@ -13,7 +13,7 @@ import ( "path/filepath" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func performRequest(r http.Handler, method, path string) *httptest.ResponseRecorder { diff --git a/Godeps/_workspace/src/github.com/gin-gonic/gin/utils_test.go b/Godeps/_workspace/src/github.com/gin-gonic/gin/utils_test.go index e2fcf4f4ad3f821708706f54c0c0bd8a976a01d3..ba0cc20d9db5a9f3a641b2e48282e8a03f5f407d 100644 --- a/Godeps/_workspace/src/github.com/gin-gonic/gin/utils_test.go +++ b/Godeps/_workspace/src/github.com/gin-gonic/gin/utils_test.go @@ -9,7 +9,7 @@ import ( "net/http" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func init() { diff --git a/Godeps/_workspace/src/github.com/gorilla/websocket/examples/autobahn/server.go b/Godeps/_workspace/src/github.com/gorilla/websocket/examples/autobahn/server.go index b7eed0da47c4cddf21b7fd9d37fc1f6e6dce0218..d96ac84dbf282d639c2619f233e124cedcb7a0d0 100644 --- a/Godeps/_workspace/src/github.com/gorilla/websocket/examples/autobahn/server.go +++ b/Godeps/_workspace/src/github.com/gorilla/websocket/examples/autobahn/server.go @@ -8,7 +8,7 @@ package main import ( "errors" "flag" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" + "github.com/gorilla/websocket" "io" "log" "net/http" diff --git a/Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/conn.go b/Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/conn.go index 00b4645a47bb9ea0790e2cebf7b3bcd766d720e4..7cc0496c3e05d930ce8e47b218b696af3cad33d4 100644 --- a/Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/conn.go +++ b/Godeps/_workspace/src/github.com/gorilla/websocket/examples/chat/conn.go @@ -5,7 +5,7 @@ package main import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" + "github.com/gorilla/websocket" "log" "net/http" "time" diff --git a/Godeps/_workspace/src/github.com/gorilla/websocket/examples/filewatch/main.go b/Godeps/_workspace/src/github.com/gorilla/websocket/examples/filewatch/main.go index 37d7433ebf93f58856211f2050caf3ade9059ded..a2c7b85fab38b96b19c9c6145b80f95cd5262dea 100644 --- a/Godeps/_workspace/src/github.com/gorilla/websocket/examples/filewatch/main.go +++ b/Godeps/_workspace/src/github.com/gorilla/websocket/examples/filewatch/main.go @@ -14,7 +14,7 @@ import ( "text/template" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" + "github.com/gorilla/websocket" ) const ( diff --git a/Godeps/_workspace/src/github.com/inconshreveable/log15/stack/stack_test.go b/Godeps/_workspace/src/github.com/inconshreveable/log15/stack/stack_test.go index 64cd7d08075a7c43b884ce6076545c30a0564990..52371b1e45ab1ac08469a56607133e18cc6716d5 100644 --- a/Godeps/_workspace/src/github.com/inconshreveable/log15/stack/stack_test.go +++ b/Godeps/_workspace/src/github.com/inconshreveable/log15/stack/stack_test.go @@ -9,7 +9,7 @@ import ( "runtime" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/inconshreveable/log15/stack" + "github.com/inconshreveable/log15/stack" ) type testType struct{} diff --git a/Godeps/_workspace/src/github.com/manucorporat/sse/sse_test.go b/Godeps/_workspace/src/github.com/manucorporat/sse/sse_test.go index f1e15440afd80e113863015035c75306fc81888c..b1c2d9bc3a2d55ad6a68ba66f225e415fbc1192c 100644 --- a/Godeps/_workspace/src/github.com/manucorporat/sse/sse_test.go +++ b/Godeps/_workspace/src/github.com/manucorporat/sse/sse_test.go @@ -9,7 +9,7 @@ import ( "net/http/httptest" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) func TestEncodeOnlyData(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go b/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go index 9e9dbc45133be54bae72d4c567d91b5624d9bc46..90c280bda102f6cf23c7370fdf43231d4c880eb6 100644 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go +++ b/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_bench_test.go @@ -3,7 +3,7 @@ package stringutil_test import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/go-stringutil" + "github.com/naoina/go-stringutil" ) var benchcaseForCamelCase = "the_quick_brown_fox_jumps_over_the_lazy_dog" diff --git a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go b/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go index 89384c2c0b3c822d4868f1092507b1cc72c57862..69c831e1238ca7e1068090be1b121b96573b05a2 100644 --- a/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go +++ b/Godeps/_workspace/src/github.com/naoina/go-stringutil/strings_test.go @@ -4,7 +4,7 @@ import ( "reflect" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/go-stringutil" + "github.com/naoina/go-stringutil" ) func TestToUpperCamelCase(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/naoina/toml/decode.go b/Godeps/_workspace/src/github.com/naoina/toml/decode.go index d9cb862404ae19d9d58a42d6401dbe2f6a32c22f..c5446fe922d5fbd2e3ca6816f6bcccd268a19e5a 100644 --- a/Godeps/_workspace/src/github.com/naoina/toml/decode.go +++ b/Godeps/_workspace/src/github.com/naoina/toml/decode.go @@ -8,7 +8,7 @@ import ( "strconv" "strings" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml/ast" + "github.com/naoina/toml/ast" ) const ( diff --git a/Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go b/Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go index 94ffdfb365ba1f69ecb48a0a9a098956abe5a2b0..b85c1c680ffc50bd35f9789434ac820140d6fb3d 100644 --- a/Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go +++ b/Godeps/_workspace/src/github.com/naoina/toml/decode_bench_test.go @@ -4,7 +4,7 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml" + "github.com/naoina/toml" ) func BenchmarkUnmarshal(b *testing.B) { diff --git a/Godeps/_workspace/src/github.com/naoina/toml/decode_test.go b/Godeps/_workspace/src/github.com/naoina/toml/decode_test.go index 17dd2e79b56155af3609167becb7975ffafe5b66..1fcae9b7abcd64a96572e7640fcd449536d415ad 100644 --- a/Godeps/_workspace/src/github.com/naoina/toml/decode_test.go +++ b/Godeps/_workspace/src/github.com/naoina/toml/decode_test.go @@ -8,7 +8,7 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml" + "github.com/naoina/toml" ) const ( diff --git a/Godeps/_workspace/src/github.com/naoina/toml/encode.go b/Godeps/_workspace/src/github.com/naoina/toml/encode.go index 94302f44d04d6166a3ee5e6401ed16f84f24e5db..1932538e67b9e4f6c3db7b14e85a49a48517d09a 100644 --- a/Godeps/_workspace/src/github.com/naoina/toml/encode.go +++ b/Godeps/_workspace/src/github.com/naoina/toml/encode.go @@ -9,7 +9,7 @@ import ( "go/ast" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/go-stringutil" + "github.com/naoina/go-stringutil" ) const ( diff --git a/Godeps/_workspace/src/github.com/naoina/toml/encode_test.go b/Godeps/_workspace/src/github.com/naoina/toml/encode_test.go index 3445c879e5756aab000beca1931bdcf125daac35..17e04fd0a9d501d30e905db2f93333040f4c1c5e 100644 --- a/Godeps/_workspace/src/github.com/naoina/toml/encode_test.go +++ b/Godeps/_workspace/src/github.com/naoina/toml/encode_test.go @@ -5,7 +5,7 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml" + "github.com/naoina/toml" ) func TestMarshal(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/naoina/toml/parse.go b/Godeps/_workspace/src/github.com/naoina/toml/parse.go index f7a3c83cdb47604ca716a0da17fd2e33b4b0ff0d..e0186662525a4ae11660a97a6c16b6c683132331 100644 --- a/Godeps/_workspace/src/github.com/naoina/toml/parse.go +++ b/Godeps/_workspace/src/github.com/naoina/toml/parse.go @@ -3,7 +3,7 @@ package toml import ( "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml/ast" + "github.com/naoina/toml/ast" ) // Parse returns an AST representation of TOML. diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/require/forward_requirements.go b/Godeps/_workspace/src/github.com/stretchr/testify/require/forward_requirements.go index 62c75b9ca033451c973d8e1b43cb551a7d518957..069d4198400a87947695b7cc7eb91ac6bededbd3 100644 --- a/Godeps/_workspace/src/github.com/stretchr/testify/require/forward_requirements.go +++ b/Godeps/_workspace/src/github.com/stretchr/testify/require/forward_requirements.go @@ -3,7 +3,7 @@ package require import ( "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) type Assertions struct { diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/require/requirements.go b/Godeps/_workspace/src/github.com/stretchr/testify/require/requirements.go index 6b10a61109031a5e61ab3766de6c12bdfbd07959..122a3f3abd874add239f666f4f97880e04f64d91 100644 --- a/Godeps/_workspace/src/github.com/stretchr/testify/require/requirements.go +++ b/Godeps/_workspace/src/github.com/stretchr/testify/require/requirements.go @@ -3,7 +3,7 @@ package require import ( "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) type TestingT interface { diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite.go b/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite.go index 4dbe6ecad250e888d05ebd8dff602628ff4e702b..ac6744d479a5d69e9cfd3723da32c8c8a91debd8 100644 --- a/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite.go +++ b/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite.go @@ -8,8 +8,8 @@ import ( "regexp" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/require" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) var matchMethod = flag.String("m", "", "regular expression to select tests of the suite to run") diff --git a/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite_test.go b/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite_test.go index 630c5869de0e97302b8d0eebcb07d82151ee692a..6a1bb2c6c0ea6d5227267bf4dcf06ae87e61186f 100644 --- a/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite_test.go +++ b/Godeps/_workspace/src/github.com/stretchr/testify/suite/suite_test.go @@ -6,7 +6,7 @@ import ( "os" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ) // This suite is intended to store values to make sure that only diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch.go index 354ebe4fee5f2bfd622b5ec8700f5de7cc45af56..ccf390c9cff4bd120180dd47b5b58e9a0c00b102 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch.go @@ -10,8 +10,8 @@ import ( "encoding/binary" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/memdb" ) type ErrBatchCorrupted struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch_test.go index e98b683cde11ad97fa83134167be6b7f74eb6b13..7fc842f4fedd6f8dbd9902945d6098d4d556b6f4 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/batch_test.go @@ -10,8 +10,8 @@ import ( "bytes" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/memdb" ) type tbRec struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/bench_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/bench_test.go index 621e52db283da81202a19a0f464ae3ab0b0a0fb4..91b426709d59a8fb0860cec31ba601f9daca3605 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/bench_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/bench_test.go @@ -15,9 +15,9 @@ import ( "runtime" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" ) func randomString(r *rand.Rand, n int) []byte { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache/cache.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache/cache.go index 9ae499311026ce392b16b641577337f946754ef0..c9670de5de6f70f4ba905df39776f67a42ff32d1 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache/cache.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache/cache.go @@ -12,7 +12,7 @@ import ( "sync/atomic" "unsafe" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) // Cacher provides interface to implements a caching functionality. diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go index 6e57fab707a08b08c1bd088dac3088c7bd6e48a9..d33d5e9c78fcf566114dce757ffe4ea6e0f0ba46 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer.go @@ -6,7 +6,7 @@ package leveldb -import "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" +import "github.com/syndtr/goleveldb/leveldb/comparer" type iComparer struct { ucmp comparer.Comparer diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go index f1ef0743e955f114cea9018d051e45d898787464..a351874ed4351f6d0abf67719bf7698d4228216a 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/corrupt_test.go @@ -9,9 +9,9 @@ package leveldb import ( "bytes" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" "io" "math/rand" "testing" diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db.go index 365d311f6f0d408ff5da18ebf9dd0a803565dca3..def86bc1aa8240e30aba67c204f0e0c311a48b37 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db.go @@ -17,14 +17,14 @@ import ( "sync/atomic" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/journal" + "github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/table" + "github.com/syndtr/goleveldb/leveldb/util" ) // DB is a LevelDB database. diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go index 2c2f409322e134a286f0d01edb1e98b697e92837..26003106ead5ad7436db63da0f49dbfcd1c2cdf1 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_compaction.go @@ -10,8 +10,8 @@ import ( "sync" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/opt" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_iter.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_iter.go index 453db5b1d20190957631cc2898b96ae72df1f2df..656ae98567f38ecae293500a2649021ec9fd525f 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_iter.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_iter.go @@ -13,9 +13,9 @@ import ( "sync" "sync/atomic" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/util" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go index 4af7403317888b03177c989614003cff84009589..0372848ff1e4f62ececce67d9abe04d8e08121bd 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_snapshot.go @@ -13,9 +13,9 @@ import ( "sync" "sync/atomic" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/util" ) type snapshotElement struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_state.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_state.go index 87cd33adc6b81ff39e6e2eb7a7b9dcf9823e8d4e..24671dd39ede09ec35cc01a5f0e9bdec926a11bc 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_state.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_state.go @@ -10,8 +10,8 @@ import ( "sync/atomic" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/journal" + "github.com/syndtr/goleveldb/leveldb/memdb" ) type memDB struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_test.go index 108fdc00b3d6cd6b072b81135c76ce45329c6f21..9d91ebf1a80e78e399b745edeb8e61bbaa3bf0c8 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_test.go @@ -23,13 +23,13 @@ import ( "time" "unsafe" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/util" ) func tkey(i int) []byte { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_util.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_util.go index 0cd4a99ec78d217d0e84d14e5f1eafece9903ade..a8a2bdf72e173d592b4eba894a2996595cb1af12 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_util.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_util.go @@ -7,11 +7,11 @@ package leveldb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/util" ) // Reader is the interface that wraps basic Get and NewIterator methods. diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_write.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_write.go index 476ec3a8384aa6bc98390a5bb70b86256054d0f8..176ee893f10c6896ceb5e2cabaa2f38426c7c1c8 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_write.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/db_write.go @@ -9,9 +9,9 @@ package leveldb import ( "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/util" ) func (db *DB) writeJournal(b *Batch) error { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors.go index f45199d11d6f916f8d7a105c83a01c9a60735792..c8bd66a5aa9ab6aded8e4782358e4621c3e019e7 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors.go @@ -7,7 +7,7 @@ package leveldb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/errors" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors/errors.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors/errors.go index a22b4b9d5722df1336e8b14dffeb97d019140681..84b5d6b7b2149744c0098d7ca31b0669554be8ed 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors/errors.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors/errors.go @@ -11,8 +11,8 @@ import ( "errors" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/util" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/external_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/external_test.go index 8ae2e50e8ea41980e5a5e2a7c3e8fb147fe67a98..b328ece4e2caffe0b1004bed2047d3a3cb56eb4d 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/external_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/external_test.go @@ -10,8 +10,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/testutil" ) var _ = testutil.Defer(func() { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter.go index fcad1fbf8474328d7b01dd20f33e357f40176b40..37c1e146bcc088a5f7dc7ba621d68f3a9c7c8509 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter.go @@ -7,7 +7,7 @@ package leveldb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/filter" ) type iFilter struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom.go index 68c925522f4fa25ced117d2b78a4785b53dcb51c..bab0e99705f59201d6920633893012938dc8a592 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom.go @@ -7,7 +7,7 @@ package filter import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) func bloomHash(key []byte) uint32 { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom_test.go index 70bfdaa54ea848419067098e7978a8f61cb9d94a..1fb56f07136f23a4314455852a242109587fbcd6 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter/bloom_test.go @@ -8,7 +8,7 @@ package filter import ( "encoding/binary" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" "testing" ) diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go index 3050fb86ae651d0dbf9de64f39df378b122825ba..a23ab05f70fe8e45c0c0a8e0e4617884219a0cbf 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter.go @@ -7,7 +7,7 @@ package iterator import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) // BasicArray is the interface that wraps basic Len and Search method. diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter_test.go index 9c9c27a686462b1afa5b2a2ffbacfba8292d7c14..1ed6d07cbb6e041e4e999112fa3ccf0ec1328c6b 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/array_iter_test.go @@ -9,8 +9,8 @@ package iterator_test import ( . "github.com/onsi/ginkgo" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + . "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/testutil" ) var _ = testutil.Defer(func() { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go index 71843607f34ae43d607f25712c91feee5ff7d950..939adbb9332bcc2ce462303b9f95c9601fada105 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter.go @@ -7,8 +7,8 @@ package iterator import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/util" ) // IteratorIndexer is the interface that wraps CommonIterator and basic Get diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter_test.go index 8d64ed8b4ad803a45f777107ebd51f695f5c692e..72a7978924ebf0aaa52eefd16ef79ac57a40f086 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/indexed_iter_test.go @@ -11,9 +11,9 @@ import ( . "github.com/onsi/ginkgo" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/comparer" + . "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/testutil" ) type keyValue struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go index f6876eea87fbfd824c77831de93b911c06084f21..c2522860b0b8c0477fec8d54068053e22de6a1d4 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter.go @@ -11,7 +11,7 @@ package iterator import ( "errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter_suite_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter_suite_test.go index 3e54f8b1977d9e29bf744acc78d28163231e77a5..5ef8d5bafb3f265754c74562d987ed2858bb174f 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter_suite_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/iter_suite_test.go @@ -3,7 +3,7 @@ package iterator_test import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/testutil" ) func TestIterator(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go index df1daffa352f21c63c16e6c6a2429f90be74ec88..1a7e29df8fbd975902e5042031cd777b9a9764ce 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter.go @@ -7,9 +7,9 @@ package iterator import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/util" ) type dir int diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter_test.go index 8ef775f31657728ff39962dfda0f6fe890d130da..e523b63e4b6694cf6e0a016b06830aefdf8e8831 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator/merged_iter_test.go @@ -10,9 +10,9 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/comparer" + . "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/testutil" ) var _ = testutil.Defer(func() { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal/journal.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal/journal.go index 4e4aae982c72c8148dd3253050e6c02bc7f8c636..6519ec660eb7110425d545d6e7154c0a447a869f 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal/journal.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal/journal.go @@ -82,8 +82,8 @@ import ( "fmt" "io" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/util" ) // These constants are part of the wire format and should not be changed. diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key.go index eeff53321e810198c67d6920ea6c437bd22eab99..572ae8150c792dd43a3cc0477d1ff44075a51db3 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key.go @@ -10,7 +10,7 @@ import ( "encoding/binary" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/errors" ) type ErrIkeyCorrupted struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key_test.go index eb9526f751f320238b90945a2dd4e8db359247cb..30eadf7847ed9b35495c2ee56f800de9fff79b84 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/key_test.go @@ -10,7 +10,7 @@ import ( "bytes" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/comparer" ) var defaultIComparer = &iComparer{comparer.DefaultComparer} diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/leveldb_suite_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/leveldb_suite_test.go index 33be15d6b59ec77c8b2ff71f8e9bf146c9b106fa..fefa007a7047c7c0f5dcf69769db92d74702a087 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/leveldb_suite_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/leveldb_suite_test.go @@ -3,7 +3,7 @@ package leveldb import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/testutil" ) func TestLevelDB(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/bench_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/bench_test.go index 51ca66ba7d1b1125136ff074d13f2b314f0d78a1..b05084caa65eb0a607b796d8819dcd0656acdf3f 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/bench_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/bench_test.go @@ -11,7 +11,7 @@ import ( "math/rand" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/comparer" ) func BenchmarkPut(b *testing.B) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go index c90c3561d25aa7dc789351348fbf6041cfaf75d8..1395bd928080f5514643e2c7d24a53d57025c702 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb.go @@ -11,10 +11,10 @@ import ( "math/rand" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/util" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_suite_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_suite_test.go index 7be1214f39d1186edb10e096581599af7b08f5b7..18c304b7f19a6c66b008e7fe2f6d879cf0a0a6ad 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_suite_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_suite_test.go @@ -3,7 +3,7 @@ package memdb import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/testutil" ) func TestMemDB(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_test.go index 131333c16a033197f9ba0da6b7fdcd6a6bbbf39f..5dd6dbc7b7bbdb1d3e252c3cc1bb1995eb99ae4a 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb/memdb_test.go @@ -10,10 +10,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/util" ) func (p *DB) TestFindLT(key []byte) (rkey, value []byte, err error) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt/options.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt/options.go index 09cf9b6cffedfe9ef4f2efaaddcdce462c5fd37f..f9a309dac6f499fffaee3138179b1c0b46bd2912 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt/options.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt/options.go @@ -8,9 +8,9 @@ package opt import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/cache" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/filter" "math" ) diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/options.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/options.go index a13abb675a960c430b5acb5084812c3794922d9e..a3d84ef60d53d4afb73ba7bdf1f848ebbb202808 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/options.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/options.go @@ -7,8 +7,8 @@ package leveldb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/opt" ) func dupOptions(o *opt.Options) *opt.Options { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session.go index cb07209eb0544b2c02d6af299c8dbd0886bb46ff..f0bba4602ca528493576243aaef1da156556cb58 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session.go @@ -12,11 +12,11 @@ import ( "os" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/journal" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/util" ) type ErrManifestCorrupted struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_compaction.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_compaction.go index 0c785f4d31ee454f618163a137413874682a07bf..7c5a79418cc4bb2a3bf70ba7314c4804e04349f9 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_compaction.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_compaction.go @@ -9,9 +9,9 @@ package leveldb import ( "sync/atomic" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/memdb" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/memdb" + "github.com/syndtr/goleveldb/leveldb/opt" ) func (s *session) pickMemdbLevel(umin, umax []byte) int { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record.go index b774bafac504552d75253d0943739e7e8229ef42..405e07bef4f1f7b881044a7e449d96b99c4bd68e 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record.go @@ -12,7 +12,7 @@ import ( "io" "strings" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/errors" ) type byteReader interface { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record_test.go index 7a18cf448a7524a4d891bec7dccb150b48f70c06..33c14875618b53cd0408e77f4819c47adf9a1994 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_record_test.go @@ -10,7 +10,7 @@ import ( "bytes" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/opt" ) func decodeEncode(v *sessionRecord) (res bool, err error) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_util.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_util.go index 740f3447e21286a394507a1c3fbf53df1d8022f6..399a788bad2de7b07974e09f14e400f99e484d06 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_util.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/session_util.go @@ -10,8 +10,8 @@ import ( "fmt" "sync/atomic" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/journal" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/journal" + "github.com/syndtr/goleveldb/leveldb/storage" ) // Logging. diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go index 9329faf7a7676b75572f4ef612e6d7e320272858..46cc9d07012e91141cae7c08903f8421c394c412 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/file_storage.go @@ -18,7 +18,7 @@ import ( "sync" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) var errFileOpen = errors.New("leveldb/storage: file still open") diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go index 8952193112728a24485df4d5cfca73ebae92ca6d..fc1c8165df1a0d05d432e47889fe8ccb0b943c7f 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/mem_storage.go @@ -11,7 +11,7 @@ import ( "os" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) const typeShift = 3 diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go index bdda8c447e241d497b6dfc41fa6812b26ae157e2..85dd70b06f9f6c8955d60b382d4a8652b1ba1292 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage/storage.go @@ -12,7 +12,7 @@ import ( "fmt" "io" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) type FileType uint32 diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage_test.go index a068113fd81ffef9cd6177a8468253f2bd3f9810..08be0bab3da3b28e9c889c50ef813f6c0603d29b 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage_test.go @@ -17,8 +17,8 @@ import ( "sync" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/util" ) const typeShift = 4 diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table.go index 57fce1314b202eea9e06bcc473c385ad3aa2489d..db386f3b5465b68faff4b7f709482bdfdb830b6f 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table.go @@ -11,12 +11,12 @@ import ( "sort" "sync/atomic" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/cache" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/table" + "github.com/syndtr/goleveldb/leveldb/util" ) // tFile holds basic information about a table. diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/block_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/block_test.go index a8580cf324784e3d1122680de1e26477db26a4f2..00e6f9eea0dd97ae892eab1934d4f096f73a1b65 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/block_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/block_test.go @@ -13,10 +13,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/util" ) type blockTesting struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/reader.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/reader.go index 0ed58fb51be12eec4c780a98f1fa84510590b417..95c369d14ece57a79ba628f8fdc1e0c7284981a4 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/reader.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/reader.go @@ -14,16 +14,16 @@ import ( "strings" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/google/go-snappy/snappy" - - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/cache" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/google/go-snappy/snappy" + + "github.com/syndtr/goleveldb/leveldb/cache" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/util" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_suite_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_suite_test.go index d35a13051497c79133aa293560897c9b63276e67..6465da6e3707c48ab28ebc176c33b80b66c0c8b3 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_suite_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_suite_test.go @@ -3,7 +3,7 @@ package table import ( "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/testutil" ) func TestTable(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_test.go index 5429c465b6938b75d1f7e39662b66f1d4a507797..4b59b31f52b42f12e8e098ea3a20d3b10d6b334e 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/table_test.go @@ -12,10 +12,10 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/util" ) type tableWrapper struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/writer.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/writer.go index f656f42199b1916facf2016f28df7c0f12df9e13..45819282b349c2c14dd729d1e8ebbf8747b0172c 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/writer.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/table/writer.go @@ -12,12 +12,12 @@ import ( "fmt" "io" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/google/go-snappy/snappy" + "github.com/google/go-snappy/snappy" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/filter" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/filter" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/util" ) func sharedPrefixLen(a, b []byte) int { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/db.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/db.go index a0995a4b7b7c83efb955bb97f46b319b35b69d3b..ec3f177a12febb5259fb9d88a5b8b58e7d37dca7 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/db.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/db.go @@ -12,9 +12,9 @@ import ( . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/util" ) type DB interface{} diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/iter.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/iter.go index 5e3cbb160d543800a09960a01c63b1c60e6ed4fd..df6d9db6a335bf388ba844ee0af918707e9caf34 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/iter.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/iter.go @@ -12,7 +12,7 @@ import ( . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/iterator" ) type IterAct int diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kv.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kv.go index 83a01a4719b84ab5da4aa0e23258fa9e057089bb..471d5708c37d826d7c5e75139f209c816b13f7c5 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kv.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kv.go @@ -12,7 +12,7 @@ import ( "sort" "strings" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/util" ) type KeyValueEntry struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kvtest.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kvtest.go index 78d981c7dcd38fc198fa4c70fd3b46a9c134d83a..a0b58f0e7252b632651a6480f32fc47e973cca01 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kvtest.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/kvtest.go @@ -13,8 +13,8 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/util" ) func KeyValueTesting(rnd *rand.Rand, kv KeyValue, p DB, setup func(KeyValue) DB, teardown func(DB)) { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/storage.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/storage.go index d515438b175e1ae785a6ae3ee500808dc7c62cdb..59c496d54c62e90afe4cd057d81f412b10edef6b 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/storage.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/storage.go @@ -18,8 +18,8 @@ import ( . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/util" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/util.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/util.go index 7ac261ddba2bd4c5056f737f2af07dd0cdca1f61..97c5294b1b5dd0c16162cd49fb55ad27274cb89a 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/util.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil/util.go @@ -15,7 +15,7 @@ import ( "github.com/onsi/ginkgo/config" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/comparer" + "github.com/syndtr/goleveldb/leveldb/comparer" ) var ( diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil_test.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil_test.go index 868f7ffab3e0df8ba7c583e05b1960529148e8ad..25bf2b29f99310e6af6ab1532ccfc9cdf1621e87 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil_test.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil_test.go @@ -9,10 +9,10 @@ package leveldb import ( . "github.com/onsi/gomega" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/testutil" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/testutil" + "github.com/syndtr/goleveldb/leveldb/util" ) type testingDB struct { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util.go index 7de9260d0d38eb3b21e5e2c5d2841695bda8a4ad..1a5bf71a3254044964beba9aee5362e5da1ed763 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util.go @@ -10,7 +10,7 @@ import ( "fmt" "sort" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/storage" + "github.com/syndtr/goleveldb/leveldb/storage" ) func shorten(str string) string { diff --git a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/version.go b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/version.go index 25ae21da97e390fb12f92a32ae44053cf247e2ba..011d982da82c13eaf18b9b2abb9c106f2c4a012e 100644 --- a/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/version.go +++ b/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/version.go @@ -10,9 +10,9 @@ import ( "sync/atomic" "unsafe" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/iterator" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/util" + "github.com/syndtr/goleveldb/leveldb/iterator" + "github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb/util" ) type tSet struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/ed25519/ed25519.go b/Godeps/_workspace/src/github.com/tendermint/ed25519/ed25519.go index 6c7e5cbc4109740ed3d2ecb517d02d63e89b84cd..48ac4a423ec0452caf979154573e15485834a25a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/ed25519/ed25519.go +++ b/Godeps/_workspace/src/github.com/tendermint/ed25519/ed25519.go @@ -14,7 +14,7 @@ import ( "crypto/subtle" "io" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/agl/ed25519/edwards25519" + "github.com/agl/ed25519/edwards25519" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/ed25519/extra25519/extra25519.go b/Godeps/_workspace/src/github.com/tendermint/ed25519/extra25519/extra25519.go index bbda91686372ac2982d68a41dac8b7fb446eb67a..571218f5516f5f679364e57cb3db1fcbf3fb3225 100644 --- a/Godeps/_workspace/src/github.com/tendermint/ed25519/extra25519/extra25519.go +++ b/Godeps/_workspace/src/github.com/tendermint/ed25519/extra25519/extra25519.go @@ -7,7 +7,7 @@ package extra25519 import ( "crypto/sha512" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/agl/ed25519/edwards25519" + "github.com/agl/ed25519/edwards25519" ) // PrivateKeyToCurve25519 converts an ed25519 private key into a corresponding diff --git a/Godeps/_workspace/src/github.com/tendermint/log15/handler.go b/Godeps/_workspace/src/github.com/tendermint/log15/handler.go index 5dc7299843978865fec11d9103ea519e1ee5af89..4c771b4ba65c25eddec2741d29863af9cb17222b 100644 --- a/Godeps/_workspace/src/github.com/tendermint/log15/handler.go +++ b/Godeps/_workspace/src/github.com/tendermint/log15/handler.go @@ -11,7 +11,7 @@ import ( "sync/atomic" "unsafe" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/inconshreveable/log15/stack" + "github.com/inconshreveable/log15/stack" ) // A Logger prints its log records by writing to a Handler. diff --git a/Godeps/_workspace/src/github.com/tendermint/log15/root.go b/Godeps/_workspace/src/github.com/tendermint/log15/root.go index 7034447afaeab3524567b74eb98c7bd3c65f7d7e..98103173063315850752f8c4752b70d09799325b 100644 --- a/Godeps/_workspace/src/github.com/tendermint/log15/root.go +++ b/Godeps/_workspace/src/github.com/tendermint/log15/root.go @@ -3,8 +3,8 @@ package log15 import ( "os" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/inconshreveable/log15/term" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/mattn/go-colorable" + "github.com/inconshreveable/log15/term" + "github.com/mattn/go-colorable" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/log15/stack/stack_test.go b/Godeps/_workspace/src/github.com/tendermint/log15/stack/stack_test.go index 64cd7d08075a7c43b884ce6076545c30a0564990..52371b1e45ab1ac08469a56607133e18cc6716d5 100644 --- a/Godeps/_workspace/src/github.com/tendermint/log15/stack/stack_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/log15/stack/stack_test.go @@ -9,7 +9,7 @@ import ( "runtime" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/inconshreveable/log15/stack" + "github.com/inconshreveable/log15/stack" ) type testType struct{} diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/account.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/account.go index d69be6e76984c195a6c235fc515cbf700614909b..9be275dbcbc2dd2895074b44496af4dac6efcaa6 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/account.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/account.go @@ -5,10 +5,10 @@ import ( "fmt" "io" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/merkle" + ptypes "github.com/tendermint/tendermint/permission/types" + "github.com/tendermint/tendermint/wire" ) // Signable is an interface for all signable things. diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_account.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_account.go index 0d37711bb35dc596281c96a1ad1e06ba85638d91..e119fc56a965de9e8b83f851b07fab6317e4f27f 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_account.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_account.go @@ -1,9 +1,9 @@ package account import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/ed25519" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/tendermint/ed25519" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) type PrivAccount struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_key.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_key.go index 3597060b52e15e9035807660e4cc2c6275e2125e..5245a2d62cdc56b0eb9f63c3cdaf6f3cee40b7a8 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_key.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/priv_key.go @@ -1,10 +1,10 @@ package account import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/ed25519" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/ed25519/extra25519" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/tendermint/ed25519" + "github.com/tendermint/ed25519/extra25519" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) // PrivKey is part of PrivAccount and state.PrivValidator. diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/pub_key.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/pub_key.go index c4bdc328946efd2923b1562dd18f1e4df94b8f9f..b5ee7dd8b058c2cea9bd31b33bf467f4fe2fec89 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/pub_key.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/pub_key.go @@ -3,11 +3,11 @@ package account import ( "bytes" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/ed25519" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/ed25519/extra25519" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/ripemd160" + "github.com/tendermint/ed25519" + "github.com/tendermint/ed25519/extra25519" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" + "golang.org/x/crypto/ripemd160" ) // PubKey is part of Account and Validator. diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature.go index 2c0b816cddfdb4f84ba1547f92721af49dec9a1f..32dc86687cc060a309d2b34266a89639050d3924 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature.go @@ -3,8 +3,8 @@ package account import ( "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) // Signature is a part of Txs and consensus Votes. diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature_test.go index 8c08dde865c652c0949d6c673510193e464a36d6..1d22cc69c60317bcbd5697ccc722867d1556ccb7 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/account/signature_test.go @@ -4,9 +4,9 @@ import ( "bytes" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/ed25519" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/tendermint/ed25519" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) func TestSignAndValidate(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/alert.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/alert.go index 497be012cd64708407554ad46cf04fbf7209ea46..c47633091d786c9c51ed40861ce8b890de856de0 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/alert.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/alert.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/sfreiberg/gotwilio" + "github.com/sfreiberg/gotwilio" ) var lastAlertUnix int64 = 0 diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/config.go index 2354e5617adec9dc143745cf456148fbe81c5528..834803facf27aded5a96a460e8279212375a4ba4 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/config.go @@ -1,7 +1,7 @@ package alert import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/log.go index 9fccbd85accab8da8660a1e8bf2064db2c2cddf8..0f0740e0c17ea42f74516a8c3592b2579804220b 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/alert/log.go @@ -1,7 +1,7 @@ package alert import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "alert") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/log.go index 68783ee2d7fc9ceb5f924de601a78292d45192e9..f04e99943b32c12669112eb74f7ba031774b9889 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/log.go @@ -1,7 +1,7 @@ package blockchain import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "blockchain") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool.go index 66be4dc820cd983b702ddd6349473fd8a5192c76..b2f3c5bd5e047c001db6cc077f52f61fc087220a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool.go @@ -5,9 +5,9 @@ import ( "sync" "time" - flow "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/mxk/go1/flowcontrol" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + flow "code.google.com/p/mxk/go1/flowcontrol" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool_test.go index 50a55b43248dc8cf49edfd90b3be6fc1098706a1..a70c96d58eaa811b0d84ef9e684207e771a7d73e 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/pool_test.go @@ -5,8 +5,8 @@ import ( "testing" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" ) type testPeer struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/reactor.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/reactor.go index bd50d5a679588550e537f29b1f174fe6089831db..b80438a7255e5d2d53f3e3a5317e495abb2031ea 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/reactor.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/reactor.go @@ -7,12 +7,12 @@ import ( "reflect" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/p2p" + sm "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/store.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/store.go index d56b606d70964433de5a1f15ca66ecbcfb9e1584..69a499291bd58c1a46590a855eaf1e7e9ee31c08 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/store.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain/store.go @@ -6,10 +6,10 @@ import ( "fmt" "io" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + dbm "github.com/tendermint/tendermint/db" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) /* diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/common/service.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/common/service.go index e000b439411e05ba69421f2889c80b59d36fa0a2..0c007f958e1773b05416095b01e2a22a48f2bc3a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/common/service.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/common/service.go @@ -39,7 +39,7 @@ func (fs *FooService) OnStop() error { package common import "sync/atomic" -import "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" +import "github.com/tendermint/log15" type Service interface { Start() (bool, error) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/common/test/mutate.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/common/test/mutate.go index 5931ae6a002627576add7d0ff09b2015a22dd449..39bf9055705c31ffd0237d32ffe6d8c6022e2656 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/common/test/mutate.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/common/test/mutate.go @@ -1,7 +1,7 @@ package test import ( - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) // Contract: !bytes.Equal(input, output) && len(input) >= len(output) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/config/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/config/log.go index 8057015d1d6e47774d521a53d98226bf7cad7ee7..3cd8f430f03a59e723a675590650f913a553168d 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/config/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/config/log.go @@ -3,7 +3,7 @@ package config import ( // We can't use github.com/tendermint/tendermint/logger // because that would create a dependency cycle. - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "config") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint/config.go index a69e321ae96fccdd5c1e85b894bba43fca4c5f16..1c44cf3123563f168c6c139bbd0c25d1cf811ca2 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint/config.go @@ -1,13 +1,13 @@ package tendermint import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml" + "github.com/naoina/toml" "os" "path" "strings" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + . "github.com/tendermint/tendermint/common" + cfg "github.com/tendermint/tendermint/config" ) func getTMRoot(rootDir string) string { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test/config.go index 35a1b9b4362a6ce6d8cf1ad8b11f05dc0fc1b154..28cf6a292db199abf6c602b59a4c4c80369bf3f4 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test/config.go @@ -3,13 +3,13 @@ package tendermint_test import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml" + "github.com/naoina/toml" "os" "path" "strings" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + . "github.com/tendermint/tendermint/common" + cfg "github.com/tendermint/tendermint/config" ) func init() { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/config.go index a9f0e602e3812fe9dd8315354bc68eddec41ccd0..8366b36c5446c0039e01e0b787cc5e15d046a5a3 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/config.go @@ -1,7 +1,7 @@ package consensus import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/height_vote_set.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/height_vote_set.go index 37e6ad6231e09455bf597abd7d2f68b06881a7b2..eb680cd6e1ba34d8a7fd627b79e274c75259e540 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/height_vote_set.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/height_vote_set.go @@ -4,8 +4,8 @@ import ( "strings" "sync" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" ) type RoundVoteSet struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/log.go index 12a5b9153d8d04bc5a6c7791ae65343be78670f5..0b3a33dba281547b4145c820460dbfd5ff1a8318 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/log.go @@ -1,7 +1,7 @@ package consensus import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "consensus") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/reactor.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/reactor.go index 0b4378ee0fe4570c2a74a96d640df4d83a1a84ba..dcf28e56b847357509782ecc66a860199e703d09 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/reactor.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/reactor.go @@ -8,13 +8,13 @@ import ( "sync" "time" - bc "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + bc "github.com/tendermint/tendermint/blockchain" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/p2p" + sm "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/state.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/state.go index 72ec17c6b4bb0df9a0e86900bc755e5f7d941f9c..9c46a765683a522fb9f9de7284e9808ff857cd61 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/state.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/state.go @@ -157,14 +157,14 @@ import ( "sync" "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - bc "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - mempl "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + bc "github.com/tendermint/tendermint/blockchain" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + mempl "github.com/tendermint/tendermint/mempool" + sm "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/test.go index eb5ac9391afa748238672187cccd1df2d81e6aba..be0066e5515ff61332f5a86e800ebebe75f7aff3 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus/test.go @@ -6,12 +6,12 @@ import ( "testing" "time" - bc "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - mempl "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + bc "github.com/tendermint/tendermint/blockchain" + dbm "github.com/tendermint/tendermint/db" + mempl "github.com/tendermint/tendermint/mempool" + "github.com/tendermint/tendermint/p2p" + sm "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" ) //------------------------------------------------------------------------------- diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/db/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/db/config.go index 2a2934ffca193e66f13cf87f8036a55a1637cea9..8c24d2fdf838c4239d425617e9d8559f1959d414 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/db/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/db/config.go @@ -1,7 +1,7 @@ package db import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/db/db.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/db/db.go index 1e4933cf89a8c2d140fa4983e9282ea6db0d6c59..7c2bdaaebce054bcd5ff2dff65c8092a59e8d921 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/db/db.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/db/db.go @@ -3,7 +3,7 @@ package db import ( "path" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) type DB interface { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/db/level_db.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/db/level_db.go index 66cf9190a9f773a6b432bd379ab9ddcaead54415..7dba589877cb986515ada0aee2763c3b698abba0 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/db/level_db.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/db/level_db.go @@ -2,12 +2,12 @@ package db import ( "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/errors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/syndtr/goleveldb/leveldb/opt" + "github.com/syndtr/goleveldb/leveldb" + "github.com/syndtr/goleveldb/leveldb/errors" + "github.com/syndtr/goleveldb/leveldb/opt" "path" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) type LevelDB struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/events/event_cache.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/events/event_cache.go index c37793f95a8a3796c00ccba2b0a7fc343cea5897..d0109ae11df6af7892704e224a8174686ce3147f 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/events/event_cache.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/events/event_cache.go @@ -1,7 +1,7 @@ package events import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/types" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/events/events.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/events/events.go index 1b9f08f96569e95dbe0f1cc1f8ea77bfc1b757ab..a4173d242a7554100f8a6f9ce3b49d70000bc63f 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/events/events.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/events/events.go @@ -3,8 +3,8 @@ package events import ( "sync" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" ) // reactors and other modules should export diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/events/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/events/log.go index 232ef667b8edc6a3ced8d579b8ae13fb7a09a07f..5b301bdf0971c67d5be7fa840d38a9864263e6eb 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/events/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/events/log.go @@ -1,7 +1,7 @@ package events import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "events") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/config.go index e5c5fdada143c0a6584de201aba2e5f8a89ccb6a..88eb6b61356c73616007c7fcbea948b4b34db103 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/config.go @@ -1,7 +1,7 @@ package logger import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/log.go index f93b21abfea32c8f07d083ccd54f65c3c881e456..b2d0a5e3ab5b98a9bb1e95fc3760ae247fdc705a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/logger/log.go @@ -3,8 +3,8 @@ package logger import ( "os" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + "github.com/tendermint/log15" + . "github.com/tendermint/tendermint/common" ) var rootHandler log15.Handler diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/log.go index 724a9a3668bf9a167ed9a5baabafe6fbd412f34b..0bc62b105489e7202c9ceef57ecca2a8fd1f0fbb 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/log.go @@ -1,7 +1,7 @@ package mempool import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "mempool") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/mempool.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/mempool.go index c1b580f481742ec2a078a971e329749f5f372140..e0e09f04ff89d80b934c108168ba931c4ece8560 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/mempool.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/mempool.go @@ -11,8 +11,8 @@ package mempool import ( "sync" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + sm "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" ) type Mempool struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/reactor.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/reactor.go index fb3ff7d74cb6b7eaa235a5868fc0c527a2884b6c..2e6e36ec654a5437c3fe1ff80ee9fcbffee92995 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/reactor.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool/reactor.go @@ -5,11 +5,11 @@ import ( "fmt" "reflect" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_node.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_node.go index 884842a60140204e424116e42496ce450ba4b01f..af9e7152a3b19bf339d30d62495389bc3a4fc4cb 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_node.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_node.go @@ -2,11 +2,11 @@ package merkle import ( "bytes" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/go.crypto/ripemd160" + "code.google.com/p/go.crypto/ripemd160" "io" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) // Node diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_proof.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_proof.go index f86efe467c415334c053a6e558b378527b94b4e1..50cacdafbb690c85db8833f14eebe5971f912363 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_proof.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_proof.go @@ -3,10 +3,10 @@ package merkle import ( "bytes" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/go.crypto/ripemd160" + "code.google.com/p/go.crypto/ripemd160" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) type IAVLProof struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_test.go index bf97067f995205d5e655bc8ef3b68f38f7125ca4..457fe4facda4463ed73a8bed3a23432414e2bca9 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_test.go @@ -4,10 +4,10 @@ import ( "bytes" "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common/test" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common/test" + "github.com/tendermint/tendermint/db" + "github.com/tendermint/tendermint/wire" "runtime" "testing" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_tree.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_tree.go index b8177f6a2499ffa210631bda37227cf1c4d97b10..4446f11d1b7bd97743cb61dc432ba8220c5aba70 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_tree.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/iavl_tree.go @@ -5,9 +5,9 @@ import ( "container/list" "sync" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + dbm "github.com/tendermint/tendermint/db" + "github.com/tendermint/tendermint/wire" ) /* diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree.go index 31ad41c16da56bf83acae10c1742803f2ec9f30b..ee65f4017e0120c2656809218f0b3e18d48fb7e7 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree.go @@ -29,10 +29,10 @@ import ( "fmt" "sort" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/go.crypto/ripemd160" + "code.google.com/p/go.crypto/ripemd160" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) func SimpleHashFromTwoHashes(left []byte, right []byte) []byte { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree_test.go index 1b673cc8f4cbc00896da3b7703dba36fc6338b27..af6ff4df926885011ea0fd429a0306acd522997a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle/simple_tree_test.go @@ -3,8 +3,8 @@ package merkle import ( "bytes" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common/test" + . "github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common/test" "fmt" "testing" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/config.go index 67e802981239b922996aa717ebba2b1301ca106e..f78e7577249e8095e024e77e41cb110f8956fbc3 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/config.go @@ -1,7 +1,7 @@ package node import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/id.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/id.go index 23c75f3451e5f42367d745937b1bcc254242c6f9..2d52213f1f351a643a366e523accc76aa6eadb0b 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/id.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/id.go @@ -1,7 +1,7 @@ package node import ( - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" + acm "github.com/tendermint/tendermint/account" "time" ) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/log.go index 73ac43eb67340eb8cafb11a0ae041f3d87b9dde3..65e5e78fe614baf888667962da9abcd9879ee615 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/log.go @@ -1,7 +1,7 @@ package node import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "node") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node.go index c30a958ce03dbcf8b1912a8c3b17693dd0f64f9e..99594a33f19537bcaad025088e557d2deea31d4d 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node.go @@ -10,21 +10,21 @@ import ( "strings" "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - bc "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - mempl "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - stypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + bc "github.com/tendermint/tendermint/blockchain" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/consensus" + dbm "github.com/tendermint/tendermint/db" + "github.com/tendermint/tendermint/events" + mempl "github.com/tendermint/tendermint/mempool" + "github.com/tendermint/tendermint/p2p" + "github.com/tendermint/tendermint/rpc" + "github.com/tendermint/tendermint/rpc/core" + "github.com/tendermint/tendermint/rpc/server" + sm "github.com/tendermint/tendermint/state" + stypes "github.com/tendermint/tendermint/state/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) import _ "net/http/pprof" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node_test.go index 01f601cf1a4a29288d1a3ba115acd5ec7340b5b3..a958c96cbb571de78c493d9205ed234ce91980f6 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/node/node_test.go @@ -4,8 +4,8 @@ import ( "testing" "time" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" + _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/p2p" ) func TestNodeStartStop(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/addrbook.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/addrbook.go index 33ec57fce086ffee562e8bae2ec0e81ce5bdf5da..9e24475104ee843278da56c132398ebf2dae7d8b 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/addrbook.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/addrbook.go @@ -14,7 +14,7 @@ import ( "sync" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/config.go index 95bf4a7c4a3b4448f0daabc5af843861b260648e..c9cbf1264f4c4441ca8395f2beb68f5d92edcc87 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/config.go @@ -1,7 +1,7 @@ package p2p import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/connection.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/connection.go index 812196794db5d70ae408aad4230422b641022f77..f0c6417805d0d77e07bcf3548dda2b8b0028e741 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/connection.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/connection.go @@ -10,9 +10,9 @@ import ( "sync/atomic" "time" - flow "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/mxk/go1/flowcontrol" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" //"github.com/tendermint/log15" + flow "code.google.com/p/mxk/go1/flowcontrol" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" //"github.com/tendermint/log15" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/listener.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/listener.go index a3ab5513865306978ae9fbd3a3d159c0c76a6bf8..131d969570a13667352a0198c2331fe04d0aabd1 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/listener.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/listener.go @@ -6,8 +6,8 @@ import ( "strconv" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/p2p/upnp" ) type Listener interface { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/log.go index 319af3567266e3b809a517c9a07b10497130d8c9..7802aa7674585029fa29a18cecd92a4f47cfdc55 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/log.go @@ -1,7 +1,7 @@ package p2p import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "p2p") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/netaddress.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/netaddress.go index 8588ff73b82a3f2276698b1f8127a652f726e5c6..0730ab94272fc933490d1df184f8c9276c8046f5 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/netaddress.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/netaddress.go @@ -10,7 +10,7 @@ import ( "strconv" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) type NetAddress struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer.go index 82ff986b917618ac1f9b5c5e74a27e522d3e2570..a03f8713bdbee2aa29921bb084e6997991af54fe 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer.go @@ -5,9 +5,9 @@ import ( "io" "net" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) type Peer struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer_set_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer_set_test.go index 75301e043a81c01aa35cd88287d13495c6a36af8..90bd86709a471ce333208984a7cb26586a36b13a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer_set_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/peer_set_test.go @@ -5,8 +5,8 @@ import ( "strings" "testing" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" ) // Returns an empty dummy peer diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/pex_reactor.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/pex_reactor.go index 2c77db13f037c052ed64398155374861ff50f30c..e203063c6e194ef4a3e2b6fe95e86662db2dbd1e 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/pex_reactor.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/pex_reactor.go @@ -8,9 +8,9 @@ import ( "reflect" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/wire" ) var pexErrInvalidMessage = errors.New("Invalid PEX message") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection.go index d00cba0e5ba6c7e1806e28db67dff27e8f3a287a..732521f44ea59edc13763e4c79471a4ae63a4208 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection.go @@ -16,13 +16,13 @@ import ( "net" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/nacl/box" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/nacl/secretbox" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/ripemd160" + "golang.org/x/crypto/nacl/box" + "golang.org/x/crypto/nacl/secretbox" + "golang.org/x/crypto/ripemd160" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) // 2 + 1024 == 1026 total frame size diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection_test.go index 32bf1aac1de263bfb7f0e1abbadab39257c59de0..28921ff72182ea2565151f9b23597a86c160c0cd 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/secret_connection_test.go @@ -5,8 +5,8 @@ import ( "io" "testing" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" ) type dummyConn struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch.go index 661aee12ea3210aceda64f9a190cf2a2ad8331cd..d260cf032ad4451d028a95abdf88cb0b2a5f5b25 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch.go @@ -7,10 +7,10 @@ import ( "strconv" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/tendermint/log15" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" ) type Reactor interface { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch_test.go index 3be0386d0cf8628b67f392e318f801fd2180ead7..ac4d35cf60270236ef81dd5f881b782842a14790 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/switch_test.go @@ -6,11 +6,11 @@ import ( "testing" "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) type PeerMessage struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/log.go index 335429fa0f6a114a7fba23745108980975e3ed40..49f53c863816e9f27a808a14e8dd03645c2ca417 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/log.go @@ -1,7 +1,7 @@ package upnp import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "upnp") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/probe.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/probe.go index 4de2f8ca84d153f410d17a90ded11c5cb0b1c34d..3f9f8ad94eb495a6aa68ac2dd8b6890790318a18 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/probe.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p/upnp/probe.go @@ -6,7 +6,7 @@ import ( "net" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) type UPNPCapabilities struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/permissions.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/permissions.go index 3fa8f3dc7e60042b49e692d75727c861e7a49e42..74242ae48e37339e50b2bd28f2d83b785554ff6d 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/permissions.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/permissions.go @@ -2,7 +2,7 @@ package types import ( "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) //------------------------------------------------------------------------------------------------ diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/snatives.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/snatives.go index 0b612bd316fb1f7f1505788b114e546bd24cbe8b..3fad9bd8f16e16b1eb4119bee82d97f4bb01bef7 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/snatives.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types/snatives.go @@ -1,7 +1,7 @@ package types import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/tendermint/tendermint/wire" ) //--------------------------------------------------------------------------------------------------- diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/client.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/client.go index a6b41cfae45636382b8f53f16c76d58d88ec9fb5..3b138c5b5b8002d6cc2b2c9940d2875d9c002b84 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/client.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/client.go @@ -7,9 +7,9 @@ import ( "io/ioutil" "net/http" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/rpc/types" + "github.com/tendermint/tendermint/wire" ) func Call(remote string, method string, params []interface{}, dest interface{}) (interface{}, error) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/log.go index bfebc78dba1d3338bcb1ab663561822184cbd0ed..8b33e2f1000da5c9b825671fa612f0dc00587ca4 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/client/log.go @@ -1,7 +1,7 @@ package rpcclient import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "rpcclient") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/accounts.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/accounts.go index 6918d8325a978ff699e9ddc75e6d83f9f80edbb9..47dc8889f5f1ed557e9568c4634fecd58354d3e6 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/accounts.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/accounts.go @@ -2,9 +2,9 @@ package core import ( "fmt" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + ctypes "github.com/tendermint/tendermint/rpc/core/types" ) func GenPrivAccount() (*ctypes.ResultGenPrivAccount, error) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/blocks.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/blocks.go index fffe358d594be4ccfe6a7383fe520b4649182241..427390a2b36945a90a80533bc4bdfe09d12b7f03 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/blocks.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/blocks.go @@ -2,9 +2,9 @@ package core import ( "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/common" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/types" ) //----------------------------------------------------------------------------- diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/config.go index 9fb3f95421e60b84cae5d83ce7781e7215d2be5d..c2593d5b55baad2cec577108e4eeacd6819ed567 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/config.go @@ -1,7 +1,7 @@ package core import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/consensus.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/consensus.go index d0f3a71e52bd4e7d1aac6f6a68769331137014c4..d6abcf72ff2e94656235820db5f43621da696689 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/consensus.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/consensus.go @@ -1,10 +1,10 @@ package core import ( - cm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + cm "github.com/tendermint/tendermint/consensus" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) func ListValidators() (*ctypes.ResultListValidators, error) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/log.go index a0dfe3d8642abca18b02ca7e220b57da4840705d..d359bee26498b53017a9aec516a65f6e2472d726 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/log.go @@ -1,7 +1,7 @@ package core import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "rpc") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/mempool.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/mempool.go index 61cd4b95ed0e592c09531515e7370db77e9c0039..eaf1d5c68ec5b84d51279c8e006a2aa20b0aff34 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/mempool.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/mempool.go @@ -2,9 +2,9 @@ package core import ( "fmt" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" ) //----------------------------------------------------------------------------- diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/names.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/names.go index b7a3dc6a619572d7bd30789073751e9348f981f7..318beaafc4447579fd829852a66a44580200d607 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/names.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/names.go @@ -3,8 +3,8 @@ package core import ( "fmt" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/types" ) func GetName(name string) (*ctypes.ResultGetName, error) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/net.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/net.go index 248600b059e5728cbab758059f7ddb47f31a4b35..7ce50312a5a22c0b651334dc781be9dc281c35c5 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/net.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/net.go @@ -1,10 +1,10 @@ package core import ( - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + dbm "github.com/tendermint/tendermint/db" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + sm "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" ) //----------------------------------------------------------------------------- diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/pipe.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/pipe.go index c2250cf1d614e6f020dbd2b216e16f7eaea85d63..1cad8013e89bdd1a1059f03ac8115dc926e2b803 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/pipe.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/pipe.go @@ -1,12 +1,12 @@ package core import ( - bc "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/blockchain" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus" - mempl "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/mempool" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - stypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + bc "github.com/tendermint/tendermint/blockchain" + "github.com/tendermint/tendermint/consensus" + mempl "github.com/tendermint/tendermint/mempool" + "github.com/tendermint/tendermint/p2p" + stypes "github.com/tendermint/tendermint/state/types" + "github.com/tendermint/tendermint/types" ) var blockStore *bc.BlockStore diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/routes.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/routes.go index af7687abf5526c3eb3646e2b4d21e90385183061..afc9586ae9f451d9014b36f8e8dae3b6e5d826b5 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/routes.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/routes.go @@ -1,7 +1,7 @@ package core import ( - rpc "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server" + rpc "github.com/tendermint/tendermint/rpc/server" ) // TODO: eliminate redundancy between here and reading code from core/ diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/txs.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/txs.go index 9e775e0adbba95b5b181847a143b7b8b4283d4b8..073b6665cb3f6584126fbf4a6c9df73813b8d987 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/txs.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/txs.go @@ -2,12 +2,12 @@ package core import ( "fmt" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/state" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/vm" ) func toVMAccount(acc *acm.Account) *vm.Account { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types/responses.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types/responses.go index bfc35523094de0ec21731046fac236a28fc845d3..e756544c7f3eba48503d54ea0056c201cf493d63 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types/responses.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types/responses.go @@ -1,10 +1,10 @@ package core_types import ( - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - stypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + stypes "github.com/tendermint/tendermint/state/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) type ResultGetStorage struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client.go index f8c76c5eddc7d8406c4ab53dc3618301de0a6c64..c2417248338a8023ea902ac52dcf67ee7dee311b 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client.go @@ -3,9 +3,9 @@ package core_client import ( "bytes" "fmt" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - rpctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + rpctypes "github.com/tendermint/tendermint/rpc/types" + "github.com/tendermint/tendermint/wire" "io/ioutil" "net/http" "net/url" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client_methods.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client_methods.go index 4d37cfcb1ffceb6b86b1bfc533cff249890632c4..29c2ac539f9404c4dea84b83760b6121184ce861 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client_methods.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/client_methods.go @@ -4,10 +4,10 @@ package core_client import ( "fmt" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - rpctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + acm "github.com/tendermint/tendermint/account" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + rpctypes "github.com/tendermint/tendermint/rpc/types" + "github.com/tendermint/tendermint/types" "io/ioutil" "net/http" ) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/log.go index 91c5ec3b95994acb808d195da4647ffdc6f61cff..54b638dc1eafc6095f18e05e47ee64dc6bbd9fd8 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/log.go @@ -1,7 +1,7 @@ package core_client import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "core_client") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/ws_client.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/ws_client.go index e150e001af96fe692ecbbfef864a58c58eba62be..f2625ec3bf1cb126423b89f0373e040f4e894001 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/ws_client.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client/ws_client.go @@ -5,11 +5,11 @@ import ( "strings" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/gorilla/websocket" + . "github.com/tendermint/tendermint/common" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/rpc/types" + "github.com/tendermint/tendermint/wire" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/handlers.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/handlers.go index b57be3057caaad545faa161a4585abc2f1a54aee..693343670872bbcd69091a650005166d2b2ec4b2 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/handlers.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/handlers.go @@ -11,13 +11,13 @@ import ( "sort" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/gorilla/websocket" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + . "github.com/tendermint/tendermint/rpc/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) func RegisterRPCFuncs(mux *http.ServeMux, funcMap map[string]*RPCFunc) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/http_server.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/http_server.go index bf55baedb22cfd37c0e5a1b349565874df2df37b..16f6a9651685aa634dc08bd621b75c354498f9e0 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/http_server.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/http_server.go @@ -10,10 +10,10 @@ import ( "runtime/debug" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/alert" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/tendermint/tendermint/alert" + . "github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/rpc/types" + "github.com/tendermint/tendermint/wire" ) func StartHTTPServer(listenAddr string, handler http.Handler) (net.Listener, error) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/log.go index aab9721fd941db6ddd8080281ef57372b8f4d17e..704e22e303fefe2ebb02575e0e4524084640d005 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/server/log.go @@ -1,7 +1,7 @@ package rpcserver import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "rpcserver") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_rpc_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_rpc_test.go index c773330c7f134cdb7e85a61ef48859dc29231140..4b5e6d1e3ab61a03f0a55b57b3ef8a4b1b44fc2d 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_rpc_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_rpc_test.go @@ -1,7 +1,7 @@ package rpctest import ( - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" + _ "github.com/tendermint/tendermint/config/tendermint_test" "testing" ) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_ws_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_ws_test.go index 7d8575eb3751d2d9d41767d38fa364bdf31dc02f..991764848866e5a2004ab765ecb93649d1e646bd 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_ws_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/client_ws_test.go @@ -4,8 +4,8 @@ import ( "fmt" "testing" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/types" ) var wsTyp = "JSONRPC" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/config.go index 51c8f87c4e3fd2102d771149eea48103b181b9e2..ef5d54339dcad7ab3459e78c1edc150a095eb63f 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/config.go @@ -1,7 +1,7 @@ package rpctest import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/helpers.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/helpers.go index 53c69a9bfcfc11625f90d71575fc7ded3b0bb014..e49c3f08f7c4888ea20b5c4cc190eaa21823c586 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/helpers.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/helpers.go @@ -5,13 +5,13 @@ import ( "strconv" "testing" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - nm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/node" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - cclient "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core_client" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + nm "github.com/tendermint/tendermint/node" + "github.com/tendermint/tendermint/p2p" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + cclient "github.com/tendermint/tendermint/rpc/core_client" + "github.com/tendermint/tendermint/types" ) // global variables for use across all tests diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/tests.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/tests.go index f08bc6db349e138a49cea2e428fbad6388b00df9..e684bbef339b23236cfc230903a665af475009ec 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/tests.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/tests.go @@ -3,8 +3,8 @@ package rpctest import ( "bytes" "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/types" "testing" ) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/ws_helpers.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/ws_helpers.go index bce4efe6b43173efc0deaf700027edfe8b141383..b86987bbcc27000cf0098d7508df17e44081d3eb 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/ws_helpers.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/test/ws_helpers.go @@ -7,12 +7,12 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/gorilla/websocket" + _ "github.com/tendermint/tendermint/config/tendermint_test" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/rpc/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) //-------------------------------------------------------------------------------- diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/block_cache.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/block_cache.go index 0d0cb0fe8f152716d67b1ef1019cdcb125d6ec28..0bbab6fa4ab471c33017e9bbfe79fab52a759080 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/block_cache.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/block_cache.go @@ -4,12 +4,12 @@ import ( "bytes" "sort" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + dbm "github.com/tendermint/tendermint/db" + "github.com/tendermint/tendermint/merkle" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) func makeStorage(db dbm.DB, root []byte) merkle.Tree { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/common.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/common.go index bb0f91ed8e3d993504ea14d0694b62af4b3afa6a..0adad0aa37cc3f6080f0f4555cf06a913fc203bd 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/common.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/common.go @@ -1,9 +1,9 @@ package state import ( - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/vm" ) type AccountGetter interface { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/execution.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/execution.go index bf9b0558dc6f7a110f87eed2fd6933491f0df96e..bdb858ab5c1fba3d9caa5a35ae02189ae1683c99 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/execution.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/execution.go @@ -5,12 +5,12 @@ import ( "errors" "fmt" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" // for GlobalPermissionAddress ... - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + ptypes "github.com/tendermint/tendermint/permission/types" // for GlobalPermissionAddress ... + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/vm" ) // NOTE: If an error occurs during block execution, state will be left diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/genesis_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/genesis_test.go index 7c91436dc1bc7abf4db453a5b40a186db7c1dacb..dfa66339e877e3b702dcc212b7815e60947bd648 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/genesis_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/genesis_test.go @@ -6,9 +6,9 @@ import ( "fmt" "testing" - tdb "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" + tdb "github.com/tendermint/tendermint/db" + ptypes "github.com/tendermint/tendermint/permission/types" + . "github.com/tendermint/tendermint/state/types" ) var chain_id = "lone_ranger" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/log.go index 6b5410463299c30998e21d24bd065de6ce3a5495..7f1d3eba2ec3a4b4dc1bf8cdc2e4aadb160a9fc7 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/log.go @@ -1,7 +1,7 @@ package state import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "state") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/permissions_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/permissions_test.go index fcaf48d95a2c16cf10a2087bf7d2a543a5b15b08..34dfc9e5d3dd27e6067532eb92e371788a5adc36 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/permissions_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/permissions_test.go @@ -7,13 +7,13 @@ import ( "testing" "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + dbm "github.com/tendermint/tendermint/db" + "github.com/tendermint/tendermint/events" + ptypes "github.com/tendermint/tendermint/permission/types" + . "github.com/tendermint/tendermint/state/types" + "github.com/tendermint/tendermint/types" ) /* diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state.go index 4abbc242e6481bca9515cec4a7c6372d13e9d3e1..20f6d134cc7ac71969ba75f5b075ee715dfabecc 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state.go @@ -6,15 +6,15 @@ import ( "io/ioutil" "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + dbm "github.com/tendermint/tendermint/db" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/merkle" + ptypes "github.com/tendermint/tendermint/permission/types" + . "github.com/tendermint/tendermint/state/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/wire" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state_test.go index d030f31942fa75f5d650f97b828a221935fdcf01..c98aac82a9bd67b3bda6fe308998146fda707343 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/state_test.go @@ -5,9 +5,9 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/account" + _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/types" ) func execTxWithState(state *State, tx types.Tx, runCall bool) error { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/test.go index ca6eae68c62a593e0d0292a26d5edb59a7a604f3..90d5003d3d72a2e25211c8d4df66a22cf211e7b5 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/test.go @@ -4,12 +4,12 @@ import ( "sort" "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + dbm "github.com/tendermint/tendermint/db" + ptypes "github.com/tendermint/tendermint/permission/types" + . "github.com/tendermint/tendermint/state/types" + "github.com/tendermint/tendermint/types" ) func RandAccount(randBalance bool, minBalance int64) (*acm.Account, *acm.PrivAccount) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache.go index 532bb896c60ca860b088d861985ae7d95253c779..8afd1cd0a750b780aca9be75218265584c18669e 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache.go @@ -1,11 +1,11 @@ package state import ( - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" // for GlobalPermissionAddress ... - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + ptypes "github.com/tendermint/tendermint/permission/types" // for GlobalPermissionAddress ... + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/vm" ) type TxCache struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache_test.go index ef6544925948eab6ddaad9b681f4331bf2454cfa..c1a2d057121ded42b20bf7dad63a22037f2e001c 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/tx_cache_test.go @@ -4,7 +4,7 @@ import ( "bytes" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/tendermint/tendermint/wire" ) func TestStateToFromVMAccount(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types/genesis.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types/genesis.go index ed90b01bf6623ac4079194db7876d513480b9aef..c956286fb510df618dbf66fc589cc9f2d49f65f1 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types/genesis.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types/genesis.go @@ -3,10 +3,10 @@ package types import ( "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + ptypes "github.com/tendermint/tendermint/permission/types" + "github.com/tendermint/tendermint/wire" ) //------------------------------------------------------------ diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/block.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/block.go index 7750f97856021762f097e73fd583634aaa53d8e3..718b6a5a5963e541964aca901c1d78cf6613ff45 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/block.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/block.go @@ -7,10 +7,10 @@ import ( "strings" "time" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/merkle" + "github.com/tendermint/tendermint/wire" ) type Block struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/config.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/config.go index 14a0192943111918cc56f8a9ddfc07d77117ef98..915778ddc99c5cd40cc0adf3c9d4c92213a05082 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/config.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/config.go @@ -1,7 +1,7 @@ package types import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/tendermint/config" ) var config cfg.Config = nil diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/events.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/events.go index 8ce11fabd92deff82351f99a1bb12aaba2c18c3c..5d717734e439e6f3c32ad1ceaf48b95f00a3fb30 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/events.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/events.go @@ -4,8 +4,8 @@ import ( "fmt" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) // Functions to generate eventId strings diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/log.go index 19855efc303c5f7c40cb0d67ee8c6ea57ac18fef..fed0c559fa7ff25625c315bf679966548bb85873 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/log.go @@ -1,7 +1,7 @@ package types import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "types") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/node.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/node.go index e548a5779c46c7e2515bd67355705f4ee9613250..bf63507434305659ea3ac3e86a69756ee029c0cb 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/node.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/node.go @@ -2,7 +2,7 @@ package types import ( "fmt" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" + acm "github.com/tendermint/tendermint/account" "strings" ) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set.go index 439da4835b675e348623714bb0438754b8adc662..646c79ad723e0e94a0f9582e201d71c23e181648 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set.go @@ -7,11 +7,11 @@ import ( "io" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/go.crypto/ripemd160" + "code.google.com/p/go.crypto/ripemd160" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/merkle" + "github.com/tendermint/tendermint/wire" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set_test.go index 49ae5fca07bb7bd6614b0580017281f491669dab..5d2d9142ba3ee36aff56f9016b3c206d7116c98a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/part_set_test.go @@ -5,7 +5,7 @@ import ( "io/ioutil" "testing" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) func TestBasicPartSet(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/priv_validator.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/priv_validator.go index aad8d118c9561fd4931e89b77f71fbef5036154b..b70afe94a758f2d5000b354d3a7755ab6b8e5b76 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/priv_validator.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/priv_validator.go @@ -8,11 +8,11 @@ import ( "math" "sync" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/ed25519" + "github.com/tendermint/ed25519" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal.go index bebfc3a87b65097f316b22a35228365cdf0acfd8..78c393f928427dcf0f910e92b9d218cc67a158c6 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal.go @@ -5,9 +5,9 @@ import ( "fmt" "io" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal_test.go index fb1e23c9ad00ee45cbbb4dfae92bac0ef9573cda..f37c11eef9048c54d6ea6d0b9f26aaf78d81feca 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/proposal_test.go @@ -3,9 +3,9 @@ package types import ( "testing" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + _ "github.com/tendermint/tendermint/config/tendermint_test" ) func TestProposalSignable(t *testing.T) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx.go index ff2534e518f3e371fda0c96c0b23b53acfebbf0d..245e32f0c14c5036a00ef553012b97713f474eaa 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx.go @@ -5,12 +5,12 @@ import ( "errors" "io" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/ripemd160" + "golang.org/x/crypto/ripemd160" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + ptypes "github.com/tendermint/tendermint/permission/types" + "github.com/tendermint/tendermint/wire" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_test.go index ad6fb584919ce406376f8d834da45d8722b501e6..61acab1567341d02b37cbf306e2a0d38e284ac0d 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_test.go @@ -3,10 +3,10 @@ package types import ( "testing" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + _ "github.com/tendermint/tendermint/config/tendermint_test" + ptypes "github.com/tendermint/tendermint/permission/types" ) var chainID string diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_utils.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_utils.go index 225c445e6792f2e828eb43cba61054b4c69499c9..3750483da3edb4513286a0fe6602e2ee114fb0ba 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_utils.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/tx_utils.go @@ -2,8 +2,8 @@ package types import ( "fmt" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" + acm "github.com/tendermint/tendermint/account" + ptypes "github.com/tendermint/tendermint/permission/types" ) type AccountGetter interface { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator.go index f6e347829f4716d8a317bee63a7d2fe9f38bef32..dbf4cbde6cea84dd684131fe2ace711289138176 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator.go @@ -5,9 +5,9 @@ import ( "fmt" "io" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) // Persistent (mostly) static data for each Validator diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set.go index 566dce4972edf531951f450c271cd934f350eca6..7dc4ee6256571c31a104d821b52837af62effb77 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set.go @@ -6,9 +6,9 @@ import ( "sort" "strings" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/merkle" + "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/merkle" ) // ValidatorSet represent a set of *Validator at a given height. diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set_test.go index 3d5d01b1d0930b87fa513d26647fac3c28a03a5c..c8b5d3075bbe6591cc3aeac4ae77a4be85d7f40e 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/validator_set_test.go @@ -1,8 +1,8 @@ package types import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" "bytes" "strings" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote.go index be6fbbef97c53434f4140dd15bd1194b20f12520..c23ca9cb807ca5ae41578ab0de163e0ee84d38ad 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote.go @@ -5,9 +5,9 @@ import ( "fmt" "io" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set.go index a1c551e9202f7b7fcf16fdaadd8b42ab143c7f5e..621e3076399dcf3afd0af9d1c7d9a2f5a6187d7a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set.go @@ -6,9 +6,9 @@ import ( "strings" "sync" - acm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + acm "github.com/tendermint/tendermint/account" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/wire" ) // VoteSet helps collect signatures from validators at each height+round diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set_test.go index 10a42f31e67c964fa91075945f7550e9b25fd59c..d521478e07a61b677e8e766c35ba6bfd8a0cdf11 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/types/vote_set_test.go @@ -4,9 +4,9 @@ import ( "bytes" "sort" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common/test" - _ "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint_test" + . "github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common/test" + _ "github.com/tendermint/tendermint/config/tendermint_test" "testing" ) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/log.go index cc097564ff5b6e0b44b2309dc57c963de187ba4c..9862495b06c299cc1f6b9a5ddb4d20f65fbd4499 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/log.go @@ -1,7 +1,7 @@ package vm import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "vm") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/native.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/native.go index e5fd2def190db4a1ce83356c6b8ec587c8ffea0a..a85bd17c5d8432ea3fd46dfc59c57652f5763638 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/native.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/native.go @@ -2,8 +2,8 @@ package vm import ( "crypto/sha256" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/go.crypto/ripemd160" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + "code.google.com/p/go.crypto/ripemd160" + . "github.com/tendermint/tendermint/common" ) var registeredNativeContracts = make(map[Word256]NativeContract) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/opcodes.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/opcodes.go index 505d536cf2ced18767aaebffb3c00b9cc3ead2d1..87e09bfdd75bc0c78f86010928f497da0abede1a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/opcodes.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/opcodes.go @@ -2,7 +2,7 @@ package vm import ( "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/gopkg.in/fatih/set.v0" + "gopkg.in/fatih/set.v0" ) type OpCode byte diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/randentropy/rand_entropy.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/randentropy/rand_entropy.go index c16221c5c2934c96c7a7827ecdbced1af1e16ff0..615fee35da59cc1d1cdaa678bdad7352277ce6f2 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/randentropy/rand_entropy.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/randentropy/rand_entropy.go @@ -2,7 +2,7 @@ package randentropy import ( crand "crypto/rand" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/sha3" + "github.com/tendermint/tendermint/vm/sha3" "io" ) diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/snative.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/snative.go index a9a5c9ee4dee933b043464852a53972c79eb25ff..2fd3b0f945f687e66542bef066d2fff5dcbf998a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/snative.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/snative.go @@ -3,8 +3,8 @@ package vm import ( "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" + . "github.com/tendermint/tendermint/common" + ptypes "github.com/tendermint/tendermint/permission/types" ) // TODO: ABI diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/stack.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/stack.go index 764d658fd53d77638e407e93f7473ba1f3d2a015..7dae3e71d7567f4170d0e9eef74e9d3e4ba65869 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/stack.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/stack.go @@ -2,7 +2,7 @@ package vm import ( "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) // Not goroutine safe diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/fake_app_state.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/fake_app_state.go index 1a328b992201a5bb976801279f3e4a3f6747924f..72dcca58e2d0e39e9a7a857c9521341f9b0b8a22 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/fake_app_state.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/fake_app_state.go @@ -1,9 +1,9 @@ package vm import ( - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/sha3" + . "github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/vm" + "github.com/tendermint/tendermint/vm/sha3" ) type FakeAppState struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/log_event_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/log_event_test.go index c0fca12dd1ab36e51dfc34d47e340a570e81119f..fa598b00e9101369398745a7de151371c1976bfc 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/log_event_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/log_event_test.go @@ -5,10 +5,10 @@ import ( "reflect" "testing" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/vm" ) var expectedData = []byte{0x10} diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/vm_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/vm_test.go index 899bb2b7b8b27e57903d42b2a9a03af20ae3a891..dc268a6a317f57cf55ffd168afaf9e827c86cc1a 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/vm_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/test/vm_test.go @@ -8,11 +8,11 @@ import ( "testing" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + ptypes "github.com/tendermint/tendermint/permission/types" + "github.com/tendermint/tendermint/types" + . "github.com/tendermint/tendermint/vm" ) func newAppState() *FakeAppState { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go index 26103be6af659c3066f6c5eafe9db342587c4008..cb9bc64ff241ab4b654500886b19efdf99e7150e 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/types.go @@ -1,8 +1,8 @@ package vm import ( - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" + . "github.com/tendermint/tendermint/common" + ptypes "github.com/tendermint/tendermint/permission/types" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go index 38ce23f7919d9bf453d2e40945314ef0a6b5825a..7d60752e3a64529fec7df4d00bc2ae1662f40311 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/vm.go @@ -6,11 +6,11 @@ import ( "fmt" "math/big" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - ptypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/permission/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm/sha3" + . "github.com/tendermint/tendermint/common" + "github.com/tendermint/tendermint/events" + ptypes "github.com/tendermint/tendermint/permission/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/vm/sha3" ) var ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/byteslice.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/byteslice.go index 8aaedd8d10f21fb520db2eaa90a973e2e41c7f54..ee4bb941cf6bd10c6d4be930e57aafe8e02054a3 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/byteslice.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/byteslice.go @@ -3,7 +3,7 @@ package wire import ( "io" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) func WriteByteSlice(bz []byte, w io.Writer, n *int64, err *error) { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/codec.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/codec.go index c032d76a7c6be57195c7f260c07bc15bbdf91e88..63edb94aa5b716410447511ddae9bf94c24cc1da 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/codec.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/codec.go @@ -4,7 +4,7 @@ import ( "bytes" "errors" "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" "io" "reflect" "time" diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/log.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/log.go index 3591db3d59596f3056cd2450bfcd58f1d7abb615..610b05f69c3cd51b50e16d29eb0855eaa7bd2dad 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/log.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/log.go @@ -1,8 +1,8 @@ package wire import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/logger" + "github.com/tendermint/log15" + "github.com/tendermint/tendermint/logger" ) var log = logger.New("module", "binary") diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect.go index 8284594de0a606afa70857495731347bc32657a2..d964d585a7b9ab62590c63e1b24230e66c4d091b 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect.go @@ -9,7 +9,7 @@ import ( "sync" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) const ( diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect_test.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect_test.go index 2af5d8a5e5f1fe36c7d7e4f8f8594fda5f747221..b21b8bf2a29645e4c7e886a7aa91782f233e899f 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect_test.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/reflect_test.go @@ -7,7 +7,7 @@ import ( "testing" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) type SimpleStruct struct { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/string.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/string.go index c0c586f309c73a00adb0cbb40c3225229c949b59..00ee3e9998fe4b9cea2541694eb2cb4ca81ad40f 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/string.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/string.go @@ -3,7 +3,7 @@ package wire import ( "io" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) // String diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/time.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/time.go index b59ea396920148854744a6bad4ee2f95909994be..fde8b8ae5c1c632500f14f0400e38a46907a4538 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/time.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/time.go @@ -4,7 +4,7 @@ import ( "io" "time" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) /* diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/util.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/util.go index 91aa6f5c31526aec683c6346381c766ebfe7b836..70e2b3ff732ca44c31acac386c57245178798275 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/util.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/util.go @@ -3,9 +3,9 @@ package wire import ( "bytes" "crypto/sha256" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/code.google.com/p/go.crypto/ripemd160" + "code.google.com/p/go.crypto/ripemd160" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) func BinaryBytes(o interface{}) []byte { diff --git a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/wire.go b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/wire.go index 9054fdb6c6c9f89973f3b1b5a450c6609452fa1c..aece054fded3a51c92dd41a4b09b770e4b7aecdb 100644 --- a/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/wire.go +++ b/Godeps/_workspace/src/github.com/tendermint/tendermint/wire/wire.go @@ -6,7 +6,7 @@ import ( "io" "reflect" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + . "github.com/tendermint/tendermint/common" ) // TODO document and maybe make it configurable. diff --git a/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors.go b/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors.go index 8c9735f1bf07cdbf0b3aa735dcd689f3324d35a0..a294580420d504bad735dd1fb206f54820ed5d93 100644 --- a/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors.go +++ b/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors.go @@ -6,7 +6,7 @@ import ( "strings" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ) var ( diff --git a/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors_test.go b/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors_test.go index 3fca7178f7dcec3f0e18951623daa5dfb2f6406c..bd12c2006e9289c86808d48dd67c4615be93a70d 100644 --- a/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors_test.go +++ b/Godeps/_workspace/src/github.com/tommy351/gin-cors/cors_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/assert" ) func init() { diff --git a/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box.go b/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box.go index 05868b65ca1572d12c1dde0a9301ec795a12ea58..ffe00baf5a48953ea58a97c2438fab39cafd037f 100644 --- a/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box.go +++ b/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box.go @@ -18,9 +18,9 @@ This package is interoperable with NaCl: http://nacl.cr.yp.to/box.html. package box import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/curve25519" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/nacl/secretbox" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/salsa20/salsa" + "golang.org/x/crypto/curve25519" + "golang.org/x/crypto/nacl/secretbox" + "golang.org/x/crypto/salsa20/salsa" "io" ) diff --git a/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box_test.go b/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box_test.go index dbae504ecf475d63ca29a46ec0a8b50b67b9b07c..481ade28aecd4fa0badbf45db45a99da85604c2f 100644 --- a/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box_test.go +++ b/Godeps/_workspace/src/golang.org/x/crypto/nacl/box/box_test.go @@ -10,7 +10,7 @@ import ( "encoding/hex" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/curve25519" + "golang.org/x/crypto/curve25519" ) func TestSealOpen(t *testing.T) { diff --git a/Godeps/_workspace/src/golang.org/x/crypto/nacl/secretbox/secretbox.go b/Godeps/_workspace/src/golang.org/x/crypto/nacl/secretbox/secretbox.go index 800cc5b5ccfb91a7cbeb974e7d53b5c880e49ae0..ed46ba2f2efef5d712645fc5d89cd8acd90dc318 100644 --- a/Godeps/_workspace/src/golang.org/x/crypto/nacl/secretbox/secretbox.go +++ b/Godeps/_workspace/src/golang.org/x/crypto/nacl/secretbox/secretbox.go @@ -18,8 +18,8 @@ This package is interoperable with NaCl: http://nacl.cr.yp.to/secretbox.html. package secretbox import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/poly1305" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/crypto/salsa20/salsa" + "golang.org/x/crypto/poly1305" + "golang.org/x/crypto/salsa20/salsa" ) // Overhead is the number of bytes of overhead when boxing a message. diff --git a/Godeps/_workspace/src/golang.org/x/net/context/withtimeout_test.go b/Godeps/_workspace/src/golang.org/x/net/context/withtimeout_test.go index 1a6006dc1ee5f7b76442afd3b3097578f168e697..a6754dc36892827e5af92fb4605edfdda3eb1a04 100644 --- a/Godeps/_workspace/src/golang.org/x/net/context/withtimeout_test.go +++ b/Godeps/_workspace/src/golang.org/x/net/context/withtimeout_test.go @@ -8,7 +8,7 @@ import ( "fmt" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/net/context" + "golang.org/x/net/context" ) func ExampleWithTimeout() { diff --git a/Godeps/_workspace/src/gopkg.in/tylerb/graceful.v1/graceful.go b/Godeps/_workspace/src/gopkg.in/tylerb/graceful.v1/graceful.go index 873bd9bd5abfafb61376aca17d0258e843e9ff85..8fa2b44e25baff413907cf45ad5bf52023314889 100644 --- a/Godeps/_workspace/src/gopkg.in/tylerb/graceful.v1/graceful.go +++ b/Godeps/_workspace/src/gopkg.in/tylerb/graceful.v1/graceful.go @@ -11,7 +11,7 @@ import ( "syscall" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/golang.org/x/net/netutil" + "golang.org/x/net/netutil" ) // Server wraps an http.Server with graceful connection handling. diff --git a/account/account.go b/account/account.go new file mode 100644 index 0000000000000000000000000000000000000000..fef07dbfdb7b3d8769c50ef7bea39c44e4a89780 --- /dev/null +++ b/account/account.go @@ -0,0 +1,74 @@ +package account + +import ( + "bytes" + "fmt" + "io" + + . "github.com/tendermint/go-common" + "github.com/tendermint/go-merkle" + "github.com/tendermint/go-wire" + ptypes "github.com/eris-ltd/eris-db/permission/types" +) + +// Signable is an interface for all signable things. +// It typically removes signatures before serializing. +type Signable interface { + WriteSignBytes(chainID string, w io.Writer, n *int, err *error) +} + +// SignBytes is a convenience method for getting the bytes to sign of a Signable. +func SignBytes(chainID string, o Signable) []byte { + buf, n, err := new(bytes.Buffer), new(int), new(error) + o.WriteSignBytes(chainID, buf, n, err) + if *err != nil { + PanicCrisis(err) + } + return buf.Bytes() +} + +// HashSignBytes is a convenience method for getting the hash of the bytes of a signable +func HashSignBytes(chainID string, o Signable) []byte { + return merkle.SimpleHashFromBinary(SignBytes(chainID, o)) +} + +//----------------------------------------------------------------------------- + +// Account resides in the application state, and is mutated by transactions +// on the blockchain. +// Serialized by wire.[read|write]Reflect +type Account struct { + Address []byte `json:"address"` + PubKey PubKey `json:"pub_key"` + Sequence int `json:"sequence"` + Balance int64 `json:"balance"` + Code []byte `json:"code"` // VM code + StorageRoot []byte `json:"storage_root"` // VM storage merkle root. + + Permissions ptypes.AccountPermissions `json:"permissions"` +} + +func (acc *Account) Copy() *Account { + accCopy := *acc + return &accCopy +} + +func (acc *Account) String() string { + if acc == nil { + return "nil-Account" + } + return fmt.Sprintf("Account{%X:%v B:%v C:%v S:%X P:%s}", acc.Address, acc.PubKey, acc.Balance, len(acc.Code), acc.StorageRoot, acc.Permissions) +} + +func AccountEncoder(o interface{}, w io.Writer, n *int, err *error) { + wire.WriteBinary(o.(*Account), w, n, err) +} + +func AccountDecoder(r io.Reader, n *int, err *error) interface{} { + return wire.ReadBinary(&Account{}, r, 0, n, err) +} + +var AccountCodec = wire.Codec{ + Encode: AccountEncoder, + Decode: AccountDecoder, +} diff --git a/account/priv_account.go b/account/priv_account.go new file mode 100644 index 0000000000000000000000000000000000000000..ebdc9585d65a66477059c76d6ec50d48620f0bc3 --- /dev/null +++ b/account/priv_account.go @@ -0,0 +1,84 @@ +package account + +import ( + "github.com/tendermint/ed25519" + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" +) + +type PrivAccount struct { + Address []byte `json:"address"` + PubKey PubKey `json:"pub_key"` + PrivKey PrivKey `json:"priv_key"` +} + +func (pA *PrivAccount) Generate(index int) *PrivAccount { + newPrivKey := pA.PrivKey.(PrivKeyEd25519).Generate(index) + newPubKey := newPrivKey.PubKey() + newAddress := newPubKey.Address() + return &PrivAccount{ + Address: newAddress, + PubKey: newPubKey, + PrivKey: newPrivKey, + } +} + +func (pA *PrivAccount) Sign(chainID string, o Signable) Signature { + return pA.PrivKey.Sign(SignBytes(chainID, o)) +} + +func (pA *PrivAccount) String() string { + return Fmt("PrivAccount{%X}", pA.Address) +} + +//---------------------------------------- + +// Generates a new account with private key. +func GenPrivAccount() *PrivAccount { + privKeyBytes := new([64]byte) + copy(privKeyBytes[:32], CRandBytes(32)) + pubKeyBytes := ed25519.MakePublicKey(privKeyBytes) + pubKey := PubKeyEd25519(*pubKeyBytes) + privKey := PrivKeyEd25519(*privKeyBytes) + return &PrivAccount{ + Address: pubKey.Address(), + PubKey: pubKey, + PrivKey: privKey, + } +} + +// Generates 32 priv key bytes from secret +func GenPrivKeyBytesFromSecret(secret string) []byte { + return wire.BinarySha256(secret) // Not Ripemd160 because we want 32 bytes. +} + +// Generates a new account with private key from SHA256 hash of a secret +func GenPrivAccountFromSecret(secret string) *PrivAccount { + privKey32 := GenPrivKeyBytesFromSecret(secret) + privKeyBytes := new([64]byte) + copy(privKeyBytes[:32], privKey32) + pubKeyBytes := ed25519.MakePublicKey(privKeyBytes) + pubKey := PubKeyEd25519(*pubKeyBytes) + privKey := PrivKeyEd25519(*privKeyBytes) + return &PrivAccount{ + Address: pubKey.Address(), + PubKey: pubKey, + PrivKey: privKey, + } +} + +func GenPrivAccountFromPrivKeyBytes(privKeyBytes []byte) *PrivAccount { + if len(privKeyBytes) != 64 { + PanicSanity(Fmt("Expected 64 bytes but got %v", len(privKeyBytes))) + } + var privKeyArray [64]byte + copy(privKeyArray[:], privKeyBytes) + pubKeyBytes := ed25519.MakePublicKey(&privKeyArray) + pubKey := PubKeyEd25519(*pubKeyBytes) + privKey := PrivKeyEd25519(privKeyArray) + return &PrivAccount{ + Address: pubKey.Address(), + PubKey: pubKey, + PrivKey: privKey, + } +} diff --git a/account/priv_key.go b/account/priv_key.go new file mode 100644 index 0000000000000000000000000000000000000000..11985fb01ed87308a66699348bdbeda03de5f57a --- /dev/null +++ b/account/priv_key.go @@ -0,0 +1,70 @@ +package account + +import ( + "github.com/tendermint/ed25519" + "github.com/tendermint/ed25519/extra25519" + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" +) + +// PrivKey is part of PrivAccount and state.PrivValidator. +type PrivKey interface { + Sign(msg []byte) Signature + PubKey() PubKey +} + +// Types of PrivKey implementations +const ( + PrivKeyTypeEd25519 = byte(0x01) +) + +// for wire.readReflect +var _ = wire.RegisterInterface( + struct{ PrivKey }{}, + wire.ConcreteType{PrivKeyEd25519{}, PrivKeyTypeEd25519}, +) + +//------------------------------------- + +// Implements PrivKey +type PrivKeyEd25519 [64]byte + +func (key PrivKeyEd25519) Sign(msg []byte) Signature { + privKeyBytes := [64]byte(key) + signatureBytes := ed25519.Sign(&privKeyBytes, msg) + return SignatureEd25519(*signatureBytes) +} + +func (privKey PrivKeyEd25519) PubKey() PubKey { + privKeyBytes := [64]byte(privKey) + return PubKeyEd25519(*ed25519.MakePublicKey(&privKeyBytes)) +} + +func (privKey PrivKeyEd25519) ToCurve25519() *[32]byte { + keyCurve25519 := new([32]byte) + privKeyBytes := [64]byte(privKey) + extra25519.PrivateKeyToCurve25519(keyCurve25519, &privKeyBytes) + return keyCurve25519 +} + +func (privKey PrivKeyEd25519) String() string { + return Fmt("PrivKeyEd25519{*****}") +} + +// Deterministically generates new priv-key bytes from key. +func (key PrivKeyEd25519) Generate(index int) PrivKeyEd25519 { + newBytes := wire.BinarySha256(struct { + PrivKey [64]byte + Index int + }{key, index}) + var newKey [64]byte + copy(newKey[:], newBytes) + return PrivKeyEd25519(newKey) +} + +func GenPrivKeyEd25519() PrivKeyEd25519 { + privKeyBytes := new([64]byte) + copy(privKeyBytes[:32], CRandBytes(32)) + ed25519.MakePublicKey(privKeyBytes) + return PrivKeyEd25519(*privKeyBytes) +} diff --git a/account/pub_key.go b/account/pub_key.go new file mode 100644 index 0000000000000000000000000000000000000000..243ab7127a429295d08c8332f883e414c21fa852 --- /dev/null +++ b/account/pub_key.go @@ -0,0 +1,90 @@ +package account + +import ( + "bytes" + + "github.com/tendermint/ed25519" + "github.com/tendermint/ed25519/extra25519" + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" + "golang.org/x/crypto/ripemd160" +) + +// PubKey is part of Account and Validator. +type PubKey interface { + Address() []byte + VerifyBytes(msg []byte, sig Signature) bool +} + +// Types of PubKey implementations +const ( + PubKeyTypeEd25519 = byte(0x01) +) + +// for wire.readReflect +var _ = wire.RegisterInterface( + struct{ PubKey }{}, + wire.ConcreteType{PubKeyEd25519{}, PubKeyTypeEd25519}, +) + +//------------------------------------- + +// Implements PubKey +type PubKeyEd25519 [32]byte + +// TODO: Slicing the array gives us length prefixing but loses the type byte. +// Revisit if we add more pubkey types. +// For now, we artificially append the type byte in front to give us backwards +// compatibility for when the pubkey wasn't fixed length array +func (pubKey PubKeyEd25519) Address() []byte { + w, n, err := new(bytes.Buffer), new(int), new(error) + wire.WriteBinary(pubKey[:], w, n, err) + if *err != nil { + PanicCrisis(*err) + } + // append type byte + encodedPubkey := append([]byte{1}, w.Bytes()...) + hasher := ripemd160.New() + hasher.Write(encodedPubkey) // does not error + return hasher.Sum(nil) +} + +// TODO: Consider returning a reason for failure, or logging a runtime type mismatch. +func (pubKey PubKeyEd25519) VerifyBytes(msg []byte, sig_ Signature) bool { + sig, ok := sig_.(SignatureEd25519) + if !ok { + return false + } + pubKeyBytes := [32]byte(pubKey) + sigBytes := [64]byte(sig) + return ed25519.Verify(&pubKeyBytes, msg, &sigBytes) +} + +// For use with golang/crypto/nacl/box +// If error, returns nil. +func (pubKey PubKeyEd25519) ToCurve25519() *[32]byte { + keyCurve25519, pubKeyBytes := new([32]byte), [32]byte(pubKey) + ok := extra25519.PublicKeyToCurve25519(keyCurve25519, &pubKeyBytes) + if !ok { + return nil + } + return keyCurve25519 +} + +func (pubKey PubKeyEd25519) String() string { + return Fmt("PubKeyEd25519{%X}", pubKey[:]) +} + +// Must return the full bytes in hex. +// Used for map keying, etc. +func (pubKey PubKeyEd25519) KeyString() string { + return Fmt("%X", pubKey[:]) +} + +func (pubKey PubKeyEd25519) Equals(other PubKey) bool { + if otherEd, ok := other.(PubKeyEd25519); ok { + return bytes.Equal(pubKey[:], otherEd[:]) + } else { + return false + } +} diff --git a/account/signature.go b/account/signature.go new file mode 100644 index 0000000000000000000000000000000000000000..2022d14004d70f7e276f3b98f9d52d96d8cb8f09 --- /dev/null +++ b/account/signature.go @@ -0,0 +1,34 @@ +package account + +import ( + "fmt" + + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" +) + +// Signature is a part of Txs and consensus Votes. +type Signature interface { + IsZero() bool + String() string +} + +// Types of Signature implementations +const ( + SignatureTypeEd25519 = byte(0x01) +) + +// for wire.readReflect +var _ = wire.RegisterInterface( + struct{ Signature }{}, + wire.ConcreteType{SignatureEd25519{}, SignatureTypeEd25519}, +) + +//------------------------------------- + +// Implements Signature +type SignatureEd25519 [64]byte + +func (sig SignatureEd25519) IsZero() bool { return len(sig) == 0 } + +func (sig SignatureEd25519) String() string { return fmt.Sprintf("/%X.../", Fingerprint(sig[:])) } diff --git a/account/signature_test.go b/account/signature_test.go new file mode 100644 index 0000000000000000000000000000000000000000..45a2947a49fc0311d9f5cc230f328d63f60ac061 --- /dev/null +++ b/account/signature_test.go @@ -0,0 +1,70 @@ +package account + +import ( + "bytes" + "testing" + + "github.com/tendermint/ed25519" + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" +) + +func TestSignAndValidate(t *testing.T) { + + privAccount := GenPrivAccount() + pubKey := privAccount.PubKey + privKey := privAccount.PrivKey + + msg := CRandBytes(128) + sig := privKey.Sign(msg) + t.Logf("msg: %X, sig: %X", msg, sig) + + // Test the signature + if !pubKey.VerifyBytes(msg, sig) { + t.Errorf("Account message signature verification failed") + } + + // Mutate the signature, just one bit. + sigEd := sig.(SignatureEd25519) + sigEd[0] ^= byte(0x01) + sig = Signature(sigEd) + + if pubKey.VerifyBytes(msg, sig) { + t.Errorf("Account message signature verification should have failed but passed instead") + } +} + +func TestBinaryDecode(t *testing.T) { + + privAccount := GenPrivAccount() + pubKey := privAccount.PubKey + privKey := privAccount.PrivKey + + msg := CRandBytes(128) + sig := privKey.Sign(msg) + t.Logf("msg: %X, sig: %X", msg, sig) + + buf, n, err := new(bytes.Buffer), new(int64), new(error) + wire.WriteBinary(sig, buf, n, err) + if *err != nil { + t.Fatalf("Failed to write Signature: %v", err) + } + + if len(buf.Bytes()) != ed25519.SignatureSize+1 { + // 1 byte TypeByte, 64 bytes signature bytes + t.Fatalf("Unexpected signature write size: %v", len(buf.Bytes())) + } + if buf.Bytes()[0] != SignatureTypeEd25519 { + t.Fatalf("Unexpected signature type byte") + } + + sig2, ok := wire.ReadBinary(SignatureEd25519{}, buf, n, err).(SignatureEd25519) + if !ok || *err != nil { + t.Fatalf("Failed to read Signature: %v", err) + } + + // Test the signature + if !pubKey.VerifyBytes(msg, sig2) { + t.Errorf("Account message signature verification failed") + } +} diff --git a/client/ws_client.go b/client/ws_client.go index d07d9598bb355d928a8f9f6d2e7b4f553786e2cd..2f562927f6a99bb19852570f46b185f0e3da6c7b 100644 --- a/client/ws_client.go +++ b/client/ws_client.go @@ -3,7 +3,7 @@ package client import ( "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" + "github.com/gorilla/websocket" "net/http" ) diff --git a/cmd/erisdbss/main.go b/cmd/erisdbss/main.go index ce3283363748e31e8a612bd8b8d4a4f360aac461..69e5542e17a0bb17b733b16a336dec9573aa81fa 100644 --- a/cmd/erisdbss/main.go +++ b/cmd/erisdbss/main.go @@ -1,7 +1,7 @@ package main import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ess "github.com/eris-ltd/eris-db/erisdb/erisdbss" "github.com/eris-ltd/eris-db/server" "os" diff --git a/erisdb/codec.go b/erisdb/codec.go index 04055df146a93af48b05a10abe4e1e71f5814979..02e96ecd0076564aefa908185110b6eadc47c285 100644 --- a/erisdb/codec.go +++ b/erisdb/codec.go @@ -1,8 +1,8 @@ package erisdb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" rpc "github.com/eris-ltd/eris-db/rpc" + "github.com/tendermint/go-wire" "io" "io/ioutil" ) @@ -19,7 +19,7 @@ func NewTCodec() rpc.Codec { // Encode to an io.Writer. func (this *TCodec) Encode(v interface{}, w io.Writer) error { var err error - var n int64 + var n int wire.WriteJSON(v, w, &n, &err) return err } diff --git a/erisdb/config.go b/erisdb/config.go index 438d6231227564f6223e8352226bb1ef76407d27..7873d89da89fe28d0afd84d6eba94da75591bcde 100644 --- a/erisdb/config.go +++ b/erisdb/config.go @@ -1,7 +1,7 @@ package erisdb import ( - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + cfg "github.com/tendermint/go-config" ) var config cfg.Config diff --git a/erisdb/erisdbss/http.go b/erisdb/erisdbss/http.go index bb52a0e34af5cfbaa484a04bfe7d92e25a10eead..be8db6cb37b8ff1084db9726fc6c8ebaa08709f7 100644 --- a/erisdb/erisdbss/http.go +++ b/erisdb/erisdbss/http.go @@ -3,18 +3,18 @@ package erisdbss import ( "bytes" "encoding/json" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - stypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + "github.com/gin-gonic/gin" + . "github.com/tendermint/go-common" + stypes "github.com/eris-ltd/eris-db/state/types" + "github.com/tendermint/tendermint/types" + "github.com/tendermint/go-wire" "github.com/eris-ltd/eris-db/server" "net/http" "os" ) const TendermintConfigDefault = `# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml +# For more information, see https:/github.com/toml-lang/toml moniker = "__MONIKER__" seeds = "" diff --git a/erisdb/erisdbss/log.go b/erisdb/erisdbss/log.go index 37760e9c26334c5751d2e5da0200e196234cda2c..719216427a0cbd239e0ae187dcfac8bf14604a72 100644 --- a/erisdb/erisdbss/log.go +++ b/erisdb/erisdbss/log.go @@ -1,7 +1,7 @@ package erisdbss import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "eris/serverserver") diff --git a/erisdb/erisdbss/server_manager.go b/erisdb/erisdbss/server_manager.go index 701e807112bf6c8e1ec75da26104dbac8592d1c3..43229a6b3c8064d07545ac78a93e2ce8e4b39207 100644 --- a/erisdb/erisdbss/server_manager.go +++ b/erisdb/erisdbss/server_manager.go @@ -3,8 +3,8 @@ package erisdbss import ( "bufio" "fmt" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" "github.com/eris-ltd/eris-db/files" "github.com/eris-ltd/eris-db/server" "os" diff --git a/erisdb/event_cache.go b/erisdb/event_cache.go index 81d4bca5d4394d8f852d4cefbfcec1b1c594f1fd..c9c2bd746cdd0b40a4eaa9011a50293fc1a33faf 100644 --- a/erisdb/event_cache.go +++ b/erisdb/event_cache.go @@ -6,7 +6,7 @@ import ( "sync" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/types" ) var ( diff --git a/erisdb/event_cache_test.go b/erisdb/event_cache_test.go index 83410eae32ca251670dfceb615e8a64d8aed40c9..2ca5d280c1b1cdb57330cb67cbaabe6e0c8cd877 100644 --- a/erisdb/event_cache_test.go +++ b/erisdb/event_cache_test.go @@ -7,8 +7,8 @@ import ( "testing" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/stretchr/testify/assert" + "github.com/tendermint/tendermint/types" ) var mockInterval = 10 * time.Millisecond diff --git a/erisdb/event_filters.go b/erisdb/event_filters.go index 0b8c6033fa58a072d8e50a76d3c3c33e25509b60..498b79ce55521146d199a316b00525f699994613 100644 --- a/erisdb/event_filters.go +++ b/erisdb/event_filters.go @@ -4,8 +4,8 @@ import ( "bytes" "encoding/hex" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" ep "github.com/eris-ltd/eris-db/erisdb/pipe" + "github.com/eris-ltd/eris-db/txs" ) // Filter for account code. diff --git a/erisdb/json_service.go b/erisdb/json_service.go index c08eec29eaa8a848daa828c335c5ba922b5324dc..97a7df78c571e45788c20c29ee66225474d5d393 100644 --- a/erisdb/json_service.go +++ b/erisdb/json_service.go @@ -2,7 +2,7 @@ package erisdb import ( "encoding/json" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" + "github.com/gin-gonic/gin" ep "github.com/eris-ltd/eris-db/erisdb/pipe" rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/server" diff --git a/erisdb/methods.go b/erisdb/methods.go index 7a27628da3939ec2b4edb1ae0102017fa8c006b4..810cb4cddc0cc8b3db939045140fb8370fee3bd3 100644 --- a/erisdb/methods.go +++ b/erisdb/methods.go @@ -3,10 +3,11 @@ package erisdb import ( "crypto/rand" "encoding/hex" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "strings" + ep "github.com/eris-ltd/eris-db/erisdb/pipe" rpc "github.com/eris-ltd/eris-db/rpc" - "strings" + "github.com/eris-ltd/eris-db/txs" ) // TODO use the method name definition file. diff --git a/erisdb/middleware_test.go b/erisdb/middleware_test.go index 2774abb2a811924b42dc35f73f2a56eef4a0f90e..7fc366ef92171c2fa9748822b501703bbc8150df 100644 --- a/erisdb/middleware_test.go +++ b/erisdb/middleware_test.go @@ -1,7 +1,7 @@ package erisdb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" ep "github.com/eris-ltd/eris-db/erisdb/pipe" "testing" ) diff --git a/erisdb/params.go b/erisdb/params.go index eb1db8d808a03015a8c9e68ba38283eff964c356..42d12d921f8da6facfb565d6c85de75ae68f64ea 100644 --- a/erisdb/params.go +++ b/erisdb/params.go @@ -1,9 +1,9 @@ package erisdb import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/account" "github.com/eris-ltd/eris-db/erisdb/pipe" + "github.com/eris-ltd/eris-db/txs" ) type ( diff --git a/erisdb/pipe/accounts.go b/erisdb/pipe/accounts.go index a12c8049f5542d252792b62cbc8b4a1ff5b95902..8dc5c2fb0b59418f243bbbb4879ada59ce35fe05 100644 --- a/erisdb/pipe/accounts.go +++ b/erisdb/pipe/accounts.go @@ -6,8 +6,8 @@ import ( "fmt" "sync" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - cmn "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" + acm "github.com/eris-ltd/eris-db/account" + cmn "github.com/tendermint/go-common" "github.com/eris-ltd/eris-db/tmsp" ) @@ -38,31 +38,31 @@ func newAccounts(erisdbApp *tmsp.ErisDBApp) *accounts { } // Generate a new Private Key Account. -func (this *accounts) GenPrivAccount() (*account.PrivAccount, error) { - pa := account.GenPrivAccount() +func (this *accounts) GenPrivAccount() (*acm.PrivAccount, error) { + pa := acm.GenPrivAccount() return pa, nil } // Generate a new Private Key Account. -func (this *accounts) GenPrivAccountFromKey(privKey []byte) (*account.PrivAccount, error) { +func (this *accounts) GenPrivAccountFromKey(privKey []byte) (*acm.PrivAccount, error) { if len(privKey) != 64 { return nil, fmt.Errorf("Private key is not 64 bytes long.") } fmt.Printf("PK BYTES FROM ACCOUNTS: %x\n", privKey) - pa := account.GenPrivAccountFromPrivKeyBytes(privKey) + pa := acm.GenPrivAccountFromPrivKeyBytes(privKey) return pa, nil } // Get all accounts. func (this *accounts) Accounts(fda []*FilterData) (*AccountList, error) { - accounts := make([]*account.Account, 0) + accounts := make([]*acm.Account, 0) state := this.erisdbApp.GetState() filter, err := this.filterFactory.NewFilter(fda) if err != nil { return nil, fmt.Errorf("Error in query: " + err.Error()) } state.GetAccounts().Iterate(func(key interface{}, value interface{}) bool { - acc := value.(*account.Account) + acc := value.(*acm.Account) if filter.Match(acc) { accounts = append(accounts, acc) } @@ -72,7 +72,7 @@ func (this *accounts) Accounts(fda []*FilterData) (*AccountList, error) { } // Get an account. -func (this *accounts) Account(address []byte) (*account.Account, error) { +func (this *accounts) Account(address []byte) (*acm.Account, error) { cache := this.erisdbApp.GetState() // NOTE: we want to read from mempool! acc := cache.GetAccount(address) if acc == nil { @@ -121,8 +121,8 @@ func (this *accounts) Storage(address []byte) (*Storage, error) { } // Create a new account. -func (this *accounts) newAcc(address []byte) *account.Account { - return &account.Account{ +func (this *accounts) newAcc(address []byte) *acm.Account { + return &acm.Account{ Address: address, PubKey: nil, Sequence: 0, @@ -165,7 +165,7 @@ func (this *AccountCodeFilter) Configure(fd *FilterData) error { } func (this *AccountCodeFilter) Match(v interface{}) bool { - acc, ok := v.(*account.Account) + acc, ok := v.(*acm.Account) if !ok { return false } @@ -196,7 +196,7 @@ func (this *AccountBalanceFilter) Configure(fd *FilterData) error { } func (this *AccountBalanceFilter) Match(v interface{}) bool { - acc, ok := v.(*account.Account) + acc, ok := v.(*acm.Account) if !ok { return false } diff --git a/erisdb/pipe/blockchain.go b/erisdb/pipe/blockchain.go index e11dc69082bc2af64ee9cc67d5d7e19906ab34b2..615b8478e1c8378e3f3ca982dfd1915ad464c196 100644 --- a/erisdb/pipe/blockchain.go +++ b/erisdb/pipe/blockchain.go @@ -2,9 +2,9 @@ package pipe import ( "fmt" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + dbm "github.com/tendermint/go-db" + "github.com/eris-ltd/eris-db/state" + "github.com/tendermint/tendermint/types" "math" "strconv" "strings" diff --git a/erisdb/pipe/config.go b/erisdb/pipe/config.go index a7e51520ff5f6865287a991ba815d026b10e4f78..6109c22531615096ab12f09283e302e384b5d323 100644 --- a/erisdb/pipe/config.go +++ b/erisdb/pipe/config.go @@ -1,8 +1,8 @@ package pipe import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" + "github.com/tendermint/log15" + cfg "github.com/tendermint/go-config" ) var log = log15.New("module", "eris/erisdb_pipe") diff --git a/erisdb/pipe/consensus.go b/erisdb/pipe/consensus.go index 69f1a7a5e8aa4b131a76ae09faf01e460b0d3e13..0e28643e7315a2689d9c372c90de9c51dfd5616c 100644 --- a/erisdb/pipe/consensus.go +++ b/erisdb/pipe/consensus.go @@ -1,7 +1,7 @@ package pipe import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/types" "github.com/eris-ltd/eris-db/tmsp" ) diff --git a/erisdb/pipe/events.go b/erisdb/pipe/events.go index f2d15bdb6f16bd3a8ec3bfc0403411b3a3955129..0b7b8d01cd1faccb30fcd8dd2e99429162e18f94 100644 --- a/erisdb/pipe/events.go +++ b/erisdb/pipe/events.go @@ -1,8 +1,8 @@ package pipe import ( - evts "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + evts "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/types" ) // TODO improve diff --git a/erisdb/pipe/namereg.go b/erisdb/pipe/namereg.go index a8e3a6ad82813e73d78fea1f91bf3f491bc5843d..f9a42a77718c18b0f39580f90de34f623f317142 100644 --- a/erisdb/pipe/namereg.go +++ b/erisdb/pipe/namereg.go @@ -6,10 +6,8 @@ import ( "fmt" "sync" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - types "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/tmsp" + "github.com/eris-ltd/eris-db/txs" ) // The net struct. @@ -58,7 +56,7 @@ func (this *namereg) Entry(key string) (*types.NameRegEntry, error) { return entry, nil } -func (this *namereg) Entries(filters []*FilterData) (*ctypes.ResultListNames, error) { +func (this *namereg) Entries(filters []*FilterData) (*ResultListNames, error) { var blockHeight int var names []*types.NameRegEntry state := this.erisdbApp.GetState() @@ -74,7 +72,12 @@ func (this *namereg) Entries(filters []*FilterData) (*ctypes.ResultListNames, er } return false }) - return &ctypes.ResultListNames{blockHeight, names}, nil + return &ResultListNames{blockHeight, names}, nil +} + +type ResultListNames struct { + BlockHeight int `json:"block_height"` + Names []*types.NameRegEntry `json:"names"` } // Filter for namereg name. This should not be used to get individual entries by name. diff --git a/erisdb/pipe/pipe.go b/erisdb/pipe/pipe.go index aa9a960c17c7b03202c6377cc27d373f560320cb..3d5f053080fff9eb60e3ad44ef2328e4a6cee08a 100644 --- a/erisdb/pipe/pipe.go +++ b/erisdb/pipe/pipe.go @@ -2,12 +2,12 @@ package pipe import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - em "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/account" + em "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/types" "github.com/eris-ltd/eris-db/tmsp" + txs "github.com/eris-ltd/eris-db/txs" ) type ( @@ -53,8 +53,8 @@ type ( } NameReg interface { - Entry(key string) (*types.NameRegEntry, error) - Entries([]*FilterData) (*ctypes.ResultListNames, error) + Entry(key string) (*txs.NameRegEntry, error) + Entries([]*FilterData) (*ResultListNames, error) } Net interface { @@ -70,12 +70,12 @@ type ( Transactor interface { Call(fromAddress, toAddress, data []byte) (*Call, error) CallCode(fromAddress, code, data []byte) (*Call, error) - BroadcastTx(tx types.Tx) (*Receipt, error) + BroadcastTx(tx txs.Tx) (*Receipt, error) Transact(privKey, address, data []byte, gasLimit, fee int64) (*Receipt, error) - TransactAndHold(privKey, address, data []byte, gasLimit, fee int64) (*types.EventDataCall, error) + TransactAndHold(privKey, address, data []byte, gasLimit, fee int64) (*txs.EventDataCall, error) TransactNameReg(privKey []byte, name, data string, amount, fee int64) (*Receipt, error) UnconfirmedTxs() (*UnconfirmedTxs, error) - SignTx(tx types.Tx, privAccounts []*account.PrivAccount) (types.Tx, error) + SignTx(tx txs.Tx, privAccounts []*account.PrivAccount) (txs.Tx, error) } ) diff --git a/erisdb/pipe/transactor.go b/erisdb/pipe/transactor.go index cbb1b5a187663be2726a305992ddad8895b3eddd..320b309aa590e13ae6bf02aa5ef7f5edfc5393a0 100644 --- a/erisdb/pipe/transactor.go +++ b/erisdb/pipe/transactor.go @@ -7,12 +7,14 @@ import ( "sync" "time" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - cmn "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - tEvents "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/vm" + "github.com/eris-ltd/eris-db/account" + "github.com/eris-ltd/eris-db/evm" + "github.com/eris-ltd/eris-db/state" + "github.com/eris-ltd/eris-db/txs" + + cmn "github.com/tendermint/go-common" + tEvents "github.com/tendermint/tendermint/events" + mintTypes "github.com/tendermint/tendermint/types" "github.com/eris-ltd/eris-db/tmsp" ) @@ -182,7 +184,7 @@ func (this *transactor) TransactAndHold(privKey, address, data []byte, gasLimit, } wc := make(chan *types.EventDataCall) subId := fmt.Sprintf("%X", rec.TxHash) - this.eventEmitter.Subscribe(subId, types.EventStringAccCall(addr), func(evt types.EventData) { + this.eventEmitter.Subscribe(subId, types.EventStringAccCall(addr), func(evt mintTypes.EventData) { event := evt.(types.EventDataCall) if bytes.Equal(event.TxID, rec.TxHash) { wc <- &event diff --git a/erisdb/pipe/types.go b/erisdb/pipe/types.go index ea8e6fa96ad9677e50c69edced594bfd07dde2f6..e0cd5e4aba3ada36b732e0b390d48cde3bca585c 100644 --- a/erisdb/pipe/types.go +++ b/erisdb/pipe/types.go @@ -1,9 +1,10 @@ package pipe import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - csus "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/consensus" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/account" + "github.com/tendermint/go-p2p" // NodeInfo (drop this!) + csus "github.com/tendermint/tendermint/consensus" + "github.com/tendermint/tendermint/types" ) type ( @@ -124,8 +125,8 @@ type ( // used in Peers and BlockchainInfo Peer struct { - nodeInfo *types.NodeInfo `json:"node_info"` - IsOutbound bool `json:"is_outbound"` + nodeInfo *p2p.NodeInfo `json:"node_info"` + IsOutbound bool `json:"is_outbound"` } // *********************************** Transactions *********************************** diff --git a/erisdb/restServer.go b/erisdb/restServer.go index e9131b0ec3a5d73afba64d81e201851ecf62c6c4..181edbba15ffdb7164d60b90adc14f7f4ba24684 100644 --- a/erisdb/restServer.go +++ b/erisdb/restServer.go @@ -3,14 +3,16 @@ package erisdb import ( "encoding/hex" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "strconv" + "strings" + + "github.com/gin-gonic/gin" + ep "github.com/eris-ltd/eris-db/erisdb/pipe" rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/server" + "github.com/eris-ltd/eris-db/txs" "github.com/eris-ltd/eris-db/util" - "strconv" - "strings" ) // Provides a REST-like web-api. Implements server.Server @@ -424,9 +426,9 @@ func (this *RestServer) handleCallCode(c *gin.Context) { } func (this *RestServer) handleTransact(c *gin.Context) { - + _, hold := c.Get("hold") - + param := &TransactParam{} errD := this.codec.Decode(param, c.Request.Body) if errD != nil { @@ -537,7 +539,7 @@ func parseTxModifier(c *gin.Context) { hold := c.Query("hold") if hold == "true" { c.Set("hold", true) - } else if (hold != "") { + } else if hold != "" { if hold != "false" { c.Writer.WriteHeader(400) c.Writer.Write([]byte("tx hold must be either 'true' or 'false', found: " + hold)) diff --git a/erisdb/serve.go b/erisdb/serve.go index 6edf56da2ab47f0dfe227f572df92b0ca9e1d315..920c043edaba155bb1f06c00b7f6f43d7f0496ce 100644 --- a/erisdb/serve.go +++ b/erisdb/serve.go @@ -6,17 +6,17 @@ import ( "bytes" "path" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" - . "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/common" - cfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config" - tmcfg "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/config/tendermint" - dbm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/db" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/node" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/p2p" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - stypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + sm "github.com/eris-ltd/eris-db/state" + stypes "github.com/eris-ltd/eris-db/state/types" + . "github.com/tendermint/go-common" + dbm "github.com/tendermint/go-db" + "github.com/tendermint/go-p2p" + "github.com/tendermint/go-wire" + "github.com/tendermint/log15" + cfg "github.com/tendermint/go-config" + tmcfg "github.com/tendermint/tendermint/config/tendermint" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/node" ep "github.com/eris-ltd/eris-db/erisdb/pipe" "github.com/eris-ltd/eris-db/server" @@ -37,7 +37,7 @@ var tmConfig cfg.Config // that. func ServeErisDB(workDir string) (*server.ServeProcess, error) { log.Info("ErisDB Serve initializing.") - errEns := EnsureDir(workDir) + errEns := EnsureDir(workDir, 0777) if errEns != nil { return nil, errEns @@ -82,7 +82,7 @@ func ServeErisDB(workDir string) (*server.ServeProcess, error) { genDoc, state = sm.MakeGenesisStateFromFile(stateDB, config.GetString("genesis_file")) state.Save() // write the gendoc to db - buf, n, err := new(bytes.Buffer), new(int64), new(error) + buf, n, err := new(bytes.Buffer), new(int), new(error) wire.WriteJSON(genDoc, buf, n, err) stateDB.Set(stypes.GenDocKey, buf.Bytes()) if *err != nil { @@ -137,7 +137,7 @@ func ServeErisDB(workDir string) (*server.ServeProcess, error) { func startNode(nd *node.Node, ready chan struct{}, shutDown <-chan struct{}) { laddr := tmConfig.GetString("node_laddr") if laddr != "" { - l := p2p.NewDefaultListener("tcp", laddr) + l := p2p.NewDefaultListener("tcp", laddr, tmConfig.GetBool("skip_upnp")) nd.AddListener(l) } diff --git a/erisdb/wsService.go b/erisdb/wsService.go index f146a50e9eefc9cffe67d15d57af2a18cf13741b..35ad0ea3ece6f1fe1d1ed105d2df3a0ef56413e5 100644 --- a/erisdb/wsService.go +++ b/erisdb/wsService.go @@ -7,7 +7,7 @@ import ( rpc "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/server" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/tendermint/tendermint/types" ) // Used for ErisDb. Implements WebSocketService. diff --git a/evm/common.go b/evm/common.go new file mode 100644 index 0000000000000000000000000000000000000000..00ab93c775f6b4ba8e29c1cc38eca28a9a7920f2 --- /dev/null +++ b/evm/common.go @@ -0,0 +1,26 @@ +package vm + +import ( + "math/big" +) + +// To256 +// +// "cast" the big int to a 256 big int (i.e., limit to) +var tt256 = new(big.Int).Lsh(big.NewInt(1), 256) +var tt256m1 = new(big.Int).Sub(new(big.Int).Lsh(big.NewInt(1), 256), big.NewInt(1)) +var tt255 = new(big.Int).Lsh(big.NewInt(1), 255) + +func U256(x *big.Int) *big.Int { + x.And(x, tt256m1) + return x +} + +func S256(x *big.Int) *big.Int { + if x.Cmp(tt255) < 0 { + return x + } else { + // We don't want to modify x, ever + return new(big.Int).Sub(x, tt256) + } +} diff --git a/evm/gas.go b/evm/gas.go new file mode 100644 index 0000000000000000000000000000000000000000..fe4a43d80d5ae2ffddbb75b44f0a5633d70bb43e --- /dev/null +++ b/evm/gas.go @@ -0,0 +1,18 @@ +package vm + +const ( + GasSha3 int64 = 1 + GasGetAccount int64 = 1 + GasStorageUpdate int64 = 1 + + GasBaseOp int64 = 0 // TODO: make this 1 + GasStackOp int64 = 1 + + GasEcRecover int64 = 1 + GasSha256Word int64 = 1 + GasSha256Base int64 = 1 + GasRipemd160Word int64 = 1 + GasRipemd160Base int64 = 1 + GasIdentityWord int64 = 1 + GasIdentityBase int64 = 1 +) diff --git a/evm/log.go b/evm/log.go new file mode 100644 index 0000000000000000000000000000000000000000..82880ae975da279da6f2cc43c4f0b547079ef790 --- /dev/null +++ b/evm/log.go @@ -0,0 +1,7 @@ +package vm + +import ( + "github.com/tendermint/go-logger" +) + +var log = logger.New("module", "vm") diff --git a/evm/native.go b/evm/native.go new file mode 100644 index 0000000000000000000000000000000000000000..207e2df1ddf086591b05df0bde7dfe545fa0b5ce --- /dev/null +++ b/evm/native.go @@ -0,0 +1,104 @@ +package vm + +import ( + "crypto/sha256" + "code.google.com/p/go.crypto/ripemd160" + . "github.com/tendermint/go-common" +) + +var registeredNativeContracts = make(map[Word256]NativeContract) + +func RegisteredNativeContract(addr Word256) bool { + _, ok := registeredNativeContracts[addr] + return ok +} + +func RegisterNativeContract(addr Word256, fn NativeContract) bool { + _, exists := registeredNativeContracts[addr] + if exists { + return false + } + registeredNativeContracts[addr] = fn + return true +} + +func init() { + registerNativeContracts() + registerSNativeContracts() +} + +func registerNativeContracts() { + // registeredNativeContracts[Int64ToWord256(1)] = ecrecoverFunc + registeredNativeContracts[Int64ToWord256(2)] = sha256Func + registeredNativeContracts[Int64ToWord256(3)] = ripemd160Func + registeredNativeContracts[Int64ToWord256(4)] = identityFunc +} + +//----------------------------------------------------------------------------- + +type NativeContract func(appState AppState, caller *Account, input []byte, gas *int64) (output []byte, err error) + +/* Removed due to C dependency +func ecrecoverFunc(appState AppState, caller *Account, input []byte, gas *int64) (output []byte, err error) { + // Deduct gas + gasRequired := GasEcRecover + if *gas < gasRequired { + return nil, ErrInsufficientGas + } else { + *gas -= gasRequired + } + // Recover + hash := input[:32] + v := byte(input[32] - 27) // ignore input[33:64], v is small. + sig := append(input[64:], v) + + recovered, err := secp256k1.RecoverPubkey(hash, sig) + if err != nil { + return nil, err + } + hashed := sha3.Sha3(recovered[1:]) + return LeftPadBytes(hashed, 32), nil +} +*/ + +func sha256Func(appState AppState, caller *Account, input []byte, gas *int64) (output []byte, err error) { + // Deduct gas + gasRequired := int64((len(input)+31)/32)*GasSha256Word + GasSha256Base + if *gas < gasRequired { + return nil, ErrInsufficientGas + } else { + *gas -= gasRequired + } + // Hash + hasher := sha256.New() + // CONTRACT: this does not err + hasher.Write(input) + return hasher.Sum(nil), nil +} + +func ripemd160Func(appState AppState, caller *Account, input []byte, gas *int64) (output []byte, err error) { + // Deduct gas + gasRequired := int64((len(input)+31)/32)*GasRipemd160Word + GasRipemd160Base + if *gas < gasRequired { + return nil, ErrInsufficientGas + } else { + *gas -= gasRequired + } + // Hash + hasher := ripemd160.New() + // CONTRACT: this does not err + hasher.Write(input) + return LeftPadBytes(hasher.Sum(nil), 32), nil +} + +func identityFunc(appState AppState, caller *Account, input []byte, gas *int64) (output []byte, err error) { + // Deduct gas + gasRequired := int64((len(input)+31)/32)*GasIdentityWord + GasIdentityBase + if *gas < gasRequired { + return nil, ErrInsufficientGas + } else { + *gas -= gasRequired + } + // Return identity + return input, nil +} diff --git a/evm/opcodes.go b/evm/opcodes.go new file mode 100644 index 0000000000000000000000000000000000000000..87e09bfdd75bc0c78f86010928f497da0abede1a --- /dev/null +++ b/evm/opcodes.go @@ -0,0 +1,354 @@ +package vm + +import ( + "fmt" + "gopkg.in/fatih/set.v0" +) + +type OpCode byte + +const ( + // Op codes + // 0x0 range - arithmetic ops + STOP OpCode = iota + ADD + MUL + SUB + DIV + SDIV + MOD + SMOD + ADDMOD + MULMOD + EXP + SIGNEXTEND +) + +const ( + LT OpCode = iota + 0x10 + GT + SLT + SGT + EQ + ISZERO + AND + OR + XOR + NOT + BYTE + + SHA3 = 0x20 +) + +const ( + // 0x30 range - closure state + ADDRESS OpCode = 0x30 + iota + BALANCE + ORIGIN + CALLER + CALLVALUE + CALLDATALOAD + CALLDATASIZE + CALLDATACOPY + CODESIZE + CODECOPY + GASPRICE_DEPRECATED + EXTCODESIZE + EXTCODECOPY +) + +const ( + + // 0x40 range - block operations + BLOCKHASH OpCode = 0x40 + iota + COINBASE + TIMESTAMP + BLOCKHEIGHT + DIFFICULTY_DEPRECATED + GASLIMIT +) + +const ( + // 0x50 range - 'storage' and execution + POP OpCode = 0x50 + iota + MLOAD + MSTORE + MSTORE8 + SLOAD + SSTORE + JUMP + JUMPI + PC + MSIZE + GAS + JUMPDEST +) + +const ( + // 0x60 range + PUSH1 OpCode = 0x60 + iota + PUSH2 + PUSH3 + PUSH4 + PUSH5 + PUSH6 + PUSH7 + PUSH8 + PUSH9 + PUSH10 + PUSH11 + PUSH12 + PUSH13 + PUSH14 + PUSH15 + PUSH16 + PUSH17 + PUSH18 + PUSH19 + PUSH20 + PUSH21 + PUSH22 + PUSH23 + PUSH24 + PUSH25 + PUSH26 + PUSH27 + PUSH28 + PUSH29 + PUSH30 + PUSH31 + PUSH32 + DUP1 + DUP2 + DUP3 + DUP4 + DUP5 + DUP6 + DUP7 + DUP8 + DUP9 + DUP10 + DUP11 + DUP12 + DUP13 + DUP14 + DUP15 + DUP16 + SWAP1 + SWAP2 + SWAP3 + SWAP4 + SWAP5 + SWAP6 + SWAP7 + SWAP8 + SWAP9 + SWAP10 + SWAP11 + SWAP12 + SWAP13 + SWAP14 + SWAP15 + SWAP16 +) + +const ( + LOG0 OpCode = 0xa0 + iota + LOG1 + LOG2 + LOG3 + LOG4 +) + +const ( + // 0xf0 range - closures + CREATE OpCode = 0xf0 + iota + CALL + CALLCODE + RETURN + + // 0x70 range - other + SUICIDE = 0xff +) + +// Since the opcodes aren't all in order we can't use a regular slice +var opCodeToString = map[OpCode]string{ + // 0x0 range - arithmetic ops + STOP: "STOP", + ADD: "ADD", + MUL: "MUL", + SUB: "SUB", + DIV: "DIV", + SDIV: "SDIV", + MOD: "MOD", + SMOD: "SMOD", + EXP: "EXP", + NOT: "NOT", + LT: "LT", + GT: "GT", + SLT: "SLT", + SGT: "SGT", + EQ: "EQ", + ISZERO: "ISZERO", + SIGNEXTEND: "SIGNEXTEND", + + // 0x10 range - bit ops + AND: "AND", + OR: "OR", + XOR: "XOR", + BYTE: "BYTE", + ADDMOD: "ADDMOD", + MULMOD: "MULMOD", + + // 0x20 range - crypto + SHA3: "SHA3", + + // 0x30 range - closure state + ADDRESS: "ADDRESS", + BALANCE: "BALANCE", + ORIGIN: "ORIGIN", + CALLER: "CALLER", + CALLVALUE: "CALLVALUE", + CALLDATALOAD: "CALLDATALOAD", + CALLDATASIZE: "CALLDATASIZE", + CALLDATACOPY: "CALLDATACOPY", + CODESIZE: "CODESIZE", + CODECOPY: "CODECOPY", + GASPRICE_DEPRECATED: "TXGASPRICE_DEPRECATED", + + // 0x40 range - block operations + BLOCKHASH: "BLOCKHASH", + COINBASE: "COINBASE", + TIMESTAMP: "TIMESTAMP", + BLOCKHEIGHT: "BLOCKHEIGHT", + DIFFICULTY_DEPRECATED: "DIFFICULTY_DEPRECATED", + GASLIMIT: "GASLIMIT", + EXTCODESIZE: "EXTCODESIZE", + EXTCODECOPY: "EXTCODECOPY", + + // 0x50 range - 'storage' and execution + POP: "POP", + //DUP: "DUP", + //SWAP: "SWAP", + MLOAD: "MLOAD", + MSTORE: "MSTORE", + MSTORE8: "MSTORE8", + SLOAD: "SLOAD", + SSTORE: "SSTORE", + JUMP: "JUMP", + JUMPI: "JUMPI", + PC: "PC", + MSIZE: "MSIZE", + GAS: "GAS", + JUMPDEST: "JUMPDEST", + + // 0x60 range - push + PUSH1: "PUSH1", + PUSH2: "PUSH2", + PUSH3: "PUSH3", + PUSH4: "PUSH4", + PUSH5: "PUSH5", + PUSH6: "PUSH6", + PUSH7: "PUSH7", + PUSH8: "PUSH8", + PUSH9: "PUSH9", + PUSH10: "PUSH10", + PUSH11: "PUSH11", + PUSH12: "PUSH12", + PUSH13: "PUSH13", + PUSH14: "PUSH14", + PUSH15: "PUSH15", + PUSH16: "PUSH16", + PUSH17: "PUSH17", + PUSH18: "PUSH18", + PUSH19: "PUSH19", + PUSH20: "PUSH20", + PUSH21: "PUSH21", + PUSH22: "PUSH22", + PUSH23: "PUSH23", + PUSH24: "PUSH24", + PUSH25: "PUSH25", + PUSH26: "PUSH26", + PUSH27: "PUSH27", + PUSH28: "PUSH28", + PUSH29: "PUSH29", + PUSH30: "PUSH30", + PUSH31: "PUSH31", + PUSH32: "PUSH32", + + DUP1: "DUP1", + DUP2: "DUP2", + DUP3: "DUP3", + DUP4: "DUP4", + DUP5: "DUP5", + DUP6: "DUP6", + DUP7: "DUP7", + DUP8: "DUP8", + DUP9: "DUP9", + DUP10: "DUP10", + DUP11: "DUP11", + DUP12: "DUP12", + DUP13: "DUP13", + DUP14: "DUP14", + DUP15: "DUP15", + DUP16: "DUP16", + + SWAP1: "SWAP1", + SWAP2: "SWAP2", + SWAP3: "SWAP3", + SWAP4: "SWAP4", + SWAP5: "SWAP5", + SWAP6: "SWAP6", + SWAP7: "SWAP7", + SWAP8: "SWAP8", + SWAP9: "SWAP9", + SWAP10: "SWAP10", + SWAP11: "SWAP11", + SWAP12: "SWAP12", + SWAP13: "SWAP13", + SWAP14: "SWAP14", + SWAP15: "SWAP15", + SWAP16: "SWAP16", + LOG0: "LOG0", + LOG1: "LOG1", + LOG2: "LOG2", + LOG3: "LOG3", + LOG4: "LOG4", + + // 0xf0 range + CREATE: "CREATE", + CALL: "CALL", + RETURN: "RETURN", + CALLCODE: "CALLCODE", + + // 0x70 range - other + SUICIDE: "SUICIDE", +} + +func (o OpCode) String() string { + str := opCodeToString[o] + if len(str) == 0 { + return fmt.Sprintf("Missing opcode 0x%x", int(o)) + } + + return str +} + +//----------------------------------------------------------------------------- + +func AnalyzeJumpDests(code []byte) (dests *set.Set) { + dests = set.New() + + for pc := uint64(0); pc < uint64(len(code)); pc++ { + var op OpCode = OpCode(code[pc]) + switch op { + case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32: + a := uint64(op) - uint64(PUSH1) + 1 + + pc += a + case JUMPDEST: + dests.Add(pc) + } + } + return +} diff --git a/evm/sha3/keccakf.go b/evm/sha3/keccakf.go new file mode 100644 index 0000000000000000000000000000000000000000..3baf13ba3d89ff1b0274711182f008dc971cb937 --- /dev/null +++ b/evm/sha3/keccakf.go @@ -0,0 +1,171 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sha3 + +// This file implements the core Keccak permutation function necessary for computing SHA3. +// This is implemented in a separate file to allow for replacement by an optimized implementation. +// Nothing in this package is exported. +// For the detailed specification, refer to the Keccak web site (http://keccak.noekeon.org/). + +// rc stores the round constants for use in the ι step. +var rc = [...]uint64{ + 0x0000000000000001, + 0x0000000000008082, + 0x800000000000808A, + 0x8000000080008000, + 0x000000000000808B, + 0x0000000080000001, + 0x8000000080008081, + 0x8000000000008009, + 0x000000000000008A, + 0x0000000000000088, + 0x0000000080008009, + 0x000000008000000A, + 0x000000008000808B, + 0x800000000000008B, + 0x8000000000008089, + 0x8000000000008003, + 0x8000000000008002, + 0x8000000000000080, + 0x000000000000800A, + 0x800000008000000A, + 0x8000000080008081, + 0x8000000000008080, + 0x0000000080000001, + 0x8000000080008008, +} + +// ro_xx represent the rotation offsets for use in the χ step. +// Defining them as const instead of in an array allows the compiler to insert constant shifts. +const ( + ro_00 = 0 + ro_01 = 36 + ro_02 = 3 + ro_03 = 41 + ro_04 = 18 + ro_05 = 1 + ro_06 = 44 + ro_07 = 10 + ro_08 = 45 + ro_09 = 2 + ro_10 = 62 + ro_11 = 6 + ro_12 = 43 + ro_13 = 15 + ro_14 = 61 + ro_15 = 28 + ro_16 = 55 + ro_17 = 25 + ro_18 = 21 + ro_19 = 56 + ro_20 = 27 + ro_21 = 20 + ro_22 = 39 + ro_23 = 8 + ro_24 = 14 +) + +// keccakF computes the complete Keccak-f function consisting of 24 rounds with a different +// constant (rc) in each round. This implementation fully unrolls the round function to avoid +// inner loops, as well as pre-calculating shift offsets. +func (d *digest) keccakF() { + for _, roundConstant := range rc { + // θ step + d.c[0] = d.a[0] ^ d.a[5] ^ d.a[10] ^ d.a[15] ^ d.a[20] + d.c[1] = d.a[1] ^ d.a[6] ^ d.a[11] ^ d.a[16] ^ d.a[21] + d.c[2] = d.a[2] ^ d.a[7] ^ d.a[12] ^ d.a[17] ^ d.a[22] + d.c[3] = d.a[3] ^ d.a[8] ^ d.a[13] ^ d.a[18] ^ d.a[23] + d.c[4] = d.a[4] ^ d.a[9] ^ d.a[14] ^ d.a[19] ^ d.a[24] + + d.d[0] = d.c[4] ^ (d.c[1]<<1 ^ d.c[1]>>63) + d.d[1] = d.c[0] ^ (d.c[2]<<1 ^ d.c[2]>>63) + d.d[2] = d.c[1] ^ (d.c[3]<<1 ^ d.c[3]>>63) + d.d[3] = d.c[2] ^ (d.c[4]<<1 ^ d.c[4]>>63) + d.d[4] = d.c[3] ^ (d.c[0]<<1 ^ d.c[0]>>63) + + d.a[0] ^= d.d[0] + d.a[1] ^= d.d[1] + d.a[2] ^= d.d[2] + d.a[3] ^= d.d[3] + d.a[4] ^= d.d[4] + d.a[5] ^= d.d[0] + d.a[6] ^= d.d[1] + d.a[7] ^= d.d[2] + d.a[8] ^= d.d[3] + d.a[9] ^= d.d[4] + d.a[10] ^= d.d[0] + d.a[11] ^= d.d[1] + d.a[12] ^= d.d[2] + d.a[13] ^= d.d[3] + d.a[14] ^= d.d[4] + d.a[15] ^= d.d[0] + d.a[16] ^= d.d[1] + d.a[17] ^= d.d[2] + d.a[18] ^= d.d[3] + d.a[19] ^= d.d[4] + d.a[20] ^= d.d[0] + d.a[21] ^= d.d[1] + d.a[22] ^= d.d[2] + d.a[23] ^= d.d[3] + d.a[24] ^= d.d[4] + + // Ï and Ï€ steps + d.b[0] = d.a[0] + d.b[1] = d.a[6]<<ro_06 ^ d.a[6]>>(64-ro_06) + d.b[2] = d.a[12]<<ro_12 ^ d.a[12]>>(64-ro_12) + d.b[3] = d.a[18]<<ro_18 ^ d.a[18]>>(64-ro_18) + d.b[4] = d.a[24]<<ro_24 ^ d.a[24]>>(64-ro_24) + d.b[5] = d.a[3]<<ro_15 ^ d.a[3]>>(64-ro_15) + d.b[6] = d.a[9]<<ro_21 ^ d.a[9]>>(64-ro_21) + d.b[7] = d.a[10]<<ro_02 ^ d.a[10]>>(64-ro_02) + d.b[8] = d.a[16]<<ro_08 ^ d.a[16]>>(64-ro_08) + d.b[9] = d.a[22]<<ro_14 ^ d.a[22]>>(64-ro_14) + d.b[10] = d.a[1]<<ro_05 ^ d.a[1]>>(64-ro_05) + d.b[11] = d.a[7]<<ro_11 ^ d.a[7]>>(64-ro_11) + d.b[12] = d.a[13]<<ro_17 ^ d.a[13]>>(64-ro_17) + d.b[13] = d.a[19]<<ro_23 ^ d.a[19]>>(64-ro_23) + d.b[14] = d.a[20]<<ro_04 ^ d.a[20]>>(64-ro_04) + d.b[15] = d.a[4]<<ro_20 ^ d.a[4]>>(64-ro_20) + d.b[16] = d.a[5]<<ro_01 ^ d.a[5]>>(64-ro_01) + d.b[17] = d.a[11]<<ro_07 ^ d.a[11]>>(64-ro_07) + d.b[18] = d.a[17]<<ro_13 ^ d.a[17]>>(64-ro_13) + d.b[19] = d.a[23]<<ro_19 ^ d.a[23]>>(64-ro_19) + d.b[20] = d.a[2]<<ro_10 ^ d.a[2]>>(64-ro_10) + d.b[21] = d.a[8]<<ro_16 ^ d.a[8]>>(64-ro_16) + d.b[22] = d.a[14]<<ro_22 ^ d.a[14]>>(64-ro_22) + d.b[23] = d.a[15]<<ro_03 ^ d.a[15]>>(64-ro_03) + d.b[24] = d.a[21]<<ro_09 ^ d.a[21]>>(64-ro_09) + + // χ step + d.a[0] = d.b[0] ^ (^d.b[1] & d.b[2]) + d.a[1] = d.b[1] ^ (^d.b[2] & d.b[3]) + d.a[2] = d.b[2] ^ (^d.b[3] & d.b[4]) + d.a[3] = d.b[3] ^ (^d.b[4] & d.b[0]) + d.a[4] = d.b[4] ^ (^d.b[0] & d.b[1]) + d.a[5] = d.b[5] ^ (^d.b[6] & d.b[7]) + d.a[6] = d.b[6] ^ (^d.b[7] & d.b[8]) + d.a[7] = d.b[7] ^ (^d.b[8] & d.b[9]) + d.a[8] = d.b[8] ^ (^d.b[9] & d.b[5]) + d.a[9] = d.b[9] ^ (^d.b[5] & d.b[6]) + d.a[10] = d.b[10] ^ (^d.b[11] & d.b[12]) + d.a[11] = d.b[11] ^ (^d.b[12] & d.b[13]) + d.a[12] = d.b[12] ^ (^d.b[13] & d.b[14]) + d.a[13] = d.b[13] ^ (^d.b[14] & d.b[10]) + d.a[14] = d.b[14] ^ (^d.b[10] & d.b[11]) + d.a[15] = d.b[15] ^ (^d.b[16] & d.b[17]) + d.a[16] = d.b[16] ^ (^d.b[17] & d.b[18]) + d.a[17] = d.b[17] ^ (^d.b[18] & d.b[19]) + d.a[18] = d.b[18] ^ (^d.b[19] & d.b[15]) + d.a[19] = d.b[19] ^ (^d.b[15] & d.b[16]) + d.a[20] = d.b[20] ^ (^d.b[21] & d.b[22]) + d.a[21] = d.b[21] ^ (^d.b[22] & d.b[23]) + d.a[22] = d.b[22] ^ (^d.b[23] & d.b[24]) + d.a[23] = d.b[23] ^ (^d.b[24] & d.b[20]) + d.a[24] = d.b[24] ^ (^d.b[20] & d.b[21]) + + // ι step + d.a[0] ^= roundConstant + } +} diff --git a/evm/sha3/sha3.go b/evm/sha3/sha3.go new file mode 100644 index 0000000000000000000000000000000000000000..da6b381f40da8a51c39aeffd5ca7791d3e74dd66 --- /dev/null +++ b/evm/sha3/sha3.go @@ -0,0 +1,224 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Package sha3 implements the SHA3 hash algorithm (formerly called Keccak) chosen by NIST in 2012. +// This file provides a SHA3 implementation which implements the standard hash.Hash interface. +// Writing input data, including padding, and reading output data are computed in this file. +// Note that the current implementation can compute the hash of an integral number of bytes only. +// This is a consequence of the hash interface in which a buffer of bytes is passed in. +// The internals of the Keccak-f function are computed in keccakf.go. +// For the detailed specification, refer to the Keccak web site (http://keccak.noekeon.org/). +package sha3 + +import ( + "encoding/binary" + "hash" +) + +// laneSize is the size in bytes of each "lane" of the internal state of SHA3 (5 * 5 * 8). +// Note that changing this size would requires using a type other than uint64 to store each lane. +const laneSize = 8 + +// sliceSize represents the dimensions of the internal state, a square matrix of +// sliceSize ** 2 lanes. This is the size of both the "rows" and "columns" dimensions in the +// terminology of the SHA3 specification. +const sliceSize = 5 + +// numLanes represents the total number of lanes in the state. +const numLanes = sliceSize * sliceSize + +// stateSize is the size in bytes of the internal state of SHA3 (5 * 5 * WSize). +const stateSize = laneSize * numLanes + +// digest represents the partial evaluation of a checksum. +// Note that capacity, and not outputSize, is the critical security parameter, as SHA3 can output +// an arbitrary number of bytes for any given capacity. The Keccak proposal recommends that +// capacity = 2*outputSize to ensure that finding a collision of size outputSize requires +// O(2^{outputSize/2}) computations (the birthday lower bound). Future standards may modify the +// capacity/outputSize ratio to allow for more output with lower cryptographic security. +type digest struct { + a [numLanes]uint64 // main state of the hash + b [numLanes]uint64 // intermediate states + c [sliceSize]uint64 // intermediate states + d [sliceSize]uint64 // intermediate states + outputSize int // desired output size in bytes + capacity int // number of bytes to leave untouched during squeeze/absorb + absorbed int // number of bytes absorbed thus far +} + +// minInt returns the lesser of two integer arguments, to simplify the absorption routine. +func minInt(v1, v2 int) int { + if v1 <= v2 { + return v1 + } + return v2 +} + +// rate returns the number of bytes of the internal state which can be absorbed or squeezed +// in between calls to the permutation function. +func (d *digest) rate() int { + return stateSize - d.capacity +} + +// Reset clears the internal state by zeroing bytes in the state buffer. +// This can be skipped for a newly-created hash state; the default zero-allocated state is correct. +func (d *digest) Reset() { + d.absorbed = 0 + for i := range d.a { + d.a[i] = 0 + } +} + +// BlockSize, required by the hash.Hash interface, does not have a standard intepretation +// for a sponge-based construction like SHA3. We return the data rate: the number of bytes which +// can be absorbed per invocation of the permutation function. For Merkle-DamgÃ¥rd based hashes +// (ie SHA1, SHA2, MD5) the output size of the internal compression function is returned. +// We consider this to be roughly equivalent because it represents the number of bytes of output +// produced per cryptographic operation. +func (d *digest) BlockSize() int { return d.rate() } + +// Size returns the output size of the hash function in bytes. +func (d *digest) Size() int { + return d.outputSize +} + +// unalignedAbsorb is a helper function for Write, which absorbs data that isn't aligned with an +// 8-byte lane. This requires shifting the individual bytes into position in a uint64. +func (d *digest) unalignedAbsorb(p []byte) { + var t uint64 + for i := len(p) - 1; i >= 0; i-- { + t <<= 8 + t |= uint64(p[i]) + } + offset := (d.absorbed) % d.rate() + t <<= 8 * uint(offset%laneSize) + d.a[offset/laneSize] ^= t + d.absorbed += len(p) +} + +// Write "absorbs" bytes into the state of the SHA3 hash, updating as needed when the sponge +// "fills up" with rate() bytes. Since lanes are stored internally as type uint64, this requires +// converting the incoming bytes into uint64s using a little endian interpretation. This +// implementation is optimized for large, aligned writes of multiples of 8 bytes (laneSize). +// Non-aligned or uneven numbers of bytes require shifting and are slower. +func (d *digest) Write(p []byte) (int, error) { + // An initial offset is needed if the we aren't absorbing to the first lane initially. + offset := d.absorbed % d.rate() + toWrite := len(p) + + // The first lane may need to absorb unaligned and/or incomplete data. + if (offset%laneSize != 0 || len(p) < 8) && len(p) > 0 { + toAbsorb := minInt(laneSize-(offset%laneSize), len(p)) + d.unalignedAbsorb(p[:toAbsorb]) + p = p[toAbsorb:] + offset = (d.absorbed) % d.rate() + + // For every rate() bytes absorbed, the state must be permuted via the F Function. + if (d.absorbed)%d.rate() == 0 { + d.keccakF() + } + } + + // This loop should absorb the bulk of the data into full, aligned lanes. + // It will call the update function as necessary. + for len(p) > 7 { + firstLane := offset / laneSize + lastLane := minInt(d.rate()/laneSize, firstLane+len(p)/laneSize) + + // This inner loop absorbs input bytes into the state in groups of 8, converted to uint64s. + for lane := firstLane; lane < lastLane; lane++ { + d.a[lane] ^= binary.LittleEndian.Uint64(p[:laneSize]) + p = p[laneSize:] + } + d.absorbed += (lastLane - firstLane) * laneSize + // For every rate() bytes absorbed, the state must be permuted via the F Function. + if (d.absorbed)%d.rate() == 0 { + d.keccakF() + } + + offset = 0 + } + + // If there are insufficient bytes to fill the final lane, an unaligned absorption. + // This should always start at a correct lane boundary though, or else it would be caught + // by the uneven opening lane case above. + if len(p) > 0 { + d.unalignedAbsorb(p) + } + + return toWrite, nil +} + +// pad computes the SHA3 padding scheme based on the number of bytes absorbed. +// The padding is a 1 bit, followed by an arbitrary number of 0s and then a final 1 bit, such that +// the input bits plus padding bits are a multiple of rate(). Adding the padding simply requires +// xoring an opening and closing bit into the appropriate lanes. +func (d *digest) pad() { + offset := d.absorbed % d.rate() + // The opening pad bit must be shifted into position based on the number of bytes absorbed + padOpenLane := offset / laneSize + d.a[padOpenLane] ^= 0x0000000000000001 << uint(8*(offset%laneSize)) + // The closing padding bit is always in the last position + padCloseLane := (d.rate() / laneSize) - 1 + d.a[padCloseLane] ^= 0x8000000000000000 +} + +// finalize prepares the hash to output data by padding and one final permutation of the state. +func (d *digest) finalize() { + d.pad() + d.keccakF() +} + +// squeeze outputs an arbitrary number of bytes from the hash state. +// Squeezing can require multiple calls to the F function (one per rate() bytes squeezed), +// although this is not the case for standard SHA3 parameters. This implementation only supports +// squeezing a single time, subsequent squeezes may lose alignment. Future implementations +// may wish to support multiple squeeze calls, for example to support use as a PRNG. +func (d *digest) squeeze(in []byte, toSqueeze int) []byte { + // Because we read in blocks of laneSize, we need enough room to read + // an integral number of lanes + needed := toSqueeze + (laneSize-toSqueeze%laneSize)%laneSize + if cap(in)-len(in) < needed { + newIn := make([]byte, len(in), len(in)+needed) + copy(newIn, in) + in = newIn + } + out := in[len(in) : len(in)+needed] + + for len(out) > 0 { + for i := 0; i < d.rate() && len(out) > 0; i += laneSize { + binary.LittleEndian.PutUint64(out[:], d.a[i/laneSize]) + out = out[laneSize:] + } + if len(out) > 0 { + d.keccakF() + } + } + return in[:len(in)+toSqueeze] // Re-slice in case we wrote extra data. +} + +// Sum applies padding to the hash state and then squeezes out the desired nubmer of output bytes. +func (d *digest) Sum(in []byte) []byte { + // Make a copy of the original hash so that caller can keep writing and summing. + dup := *d + dup.finalize() + return dup.squeeze(in, dup.outputSize) +} + +// The NewKeccakX constructors enable initializing a hash in any of the four recommend sizes +// from the Keccak specification, all of which set capacity=2*outputSize. Note that the final +// NIST standard for SHA3 may specify different input/output lengths. +// The output size is indicated in bits but converted into bytes internally. +func NewKeccak224() hash.Hash { return &digest{outputSize: 224 / 8, capacity: 2 * 224 / 8} } +func NewKeccak256() hash.Hash { return &digest{outputSize: 256 / 8, capacity: 2 * 256 / 8} } +func NewKeccak384() hash.Hash { return &digest{outputSize: 384 / 8, capacity: 2 * 384 / 8} } +func NewKeccak512() hash.Hash { return &digest{outputSize: 512 / 8, capacity: 2 * 512 / 8} } + +func Sha3(data ...[]byte) []byte { + d := NewKeccak256() + for _, b := range data { + d.Write(b) + } + return d.Sum(nil) +} diff --git a/evm/snative.go b/evm/snative.go new file mode 100644 index 0000000000000000000000000000000000000000..9c50cd4e4ba2c21ac09086fe8eac0f9828c4dd44 --- /dev/null +++ b/evm/snative.go @@ -0,0 +1,233 @@ +package vm + +import ( + "fmt" + + . "github.com/tendermint/go-common" + ptypes "github.com/eris-ltd/eris-db/permission/types" +) + +// TODO: ABI +//------------------------------------------------------------------------------------------------ +// Registered SNative contracts + +func registerSNativeContracts() { + registeredNativeContracts[LeftPadWord256([]byte("has_base"))] = hasBasePerm + registeredNativeContracts[LeftPadWord256([]byte("set_base"))] = setBasePerm + registeredNativeContracts[LeftPadWord256([]byte("unset_base"))] = unsetBasePerm + registeredNativeContracts[LeftPadWord256([]byte("set_global"))] = setGlobalPerm + registeredNativeContracts[LeftPadWord256([]byte("has_role"))] = hasRole + registeredNativeContracts[LeftPadWord256([]byte("add_role"))] = addRole + registeredNativeContracts[LeftPadWord256([]byte("rm_role"))] = rmRole +} + +//----------------------------------------------------------------------------- +// snative are native contracts that can access and modify an account's permissions + +// TODO: catch errors, log em, return 0s to the vm (should some errors cause exceptions though?) + +func hasBasePerm(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) { + if !HasPermission(appState, caller, ptypes.HasBase) { + return nil, ErrInvalidPermission{caller.Address, "has_base"} + } + if len(args) != 2*32 { + return nil, fmt.Errorf("hasBasePerm() takes two arguments (address, permFlag)") + } + addr, permNum := returnTwoArgs(args) + vmAcc := appState.GetAccount(addr) + if vmAcc == nil { + return nil, fmt.Errorf("Unknown account %X", addr) + } + permN := ptypes.PermFlag(Uint64FromWord256(permNum)) // already shifted + if !ValidPermN(permN) { + return nil, ptypes.ErrInvalidPermission(permN) + } + var permInt byte + if HasPermission(appState, vmAcc, permN) { + permInt = 0x1 + } else { + permInt = 0x0 + } + dbg.Printf("snative.hasBasePerm(0x%X, %b) = %v\n", addr.Postfix(20), permN, permInt) + return LeftPadWord256([]byte{permInt}).Bytes(), nil +} + +func setBasePerm(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) { + if !HasPermission(appState, caller, ptypes.SetBase) { + return nil, ErrInvalidPermission{caller.Address, "set_base"} + } + if len(args) != 3*32 { + return nil, fmt.Errorf("setBase() takes three arguments (address, permFlag, permission value)") + } + addr, permNum, perm := returnThreeArgs(args) + vmAcc := appState.GetAccount(addr) + if vmAcc == nil { + return nil, fmt.Errorf("Unknown account %X", addr) + } + permN := ptypes.PermFlag(Uint64FromWord256(permNum)) + if !ValidPermN(permN) { + return nil, ptypes.ErrInvalidPermission(permN) + } + permV := !perm.IsZero() + if err = vmAcc.Permissions.Base.Set(permN, permV); err != nil { + return nil, err + } + appState.UpdateAccount(vmAcc) + dbg.Printf("snative.setBasePerm(0x%X, %b, %v)\n", addr.Postfix(20), permN, permV) + return perm.Bytes(), nil +} + +func unsetBasePerm(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) { + if !HasPermission(appState, caller, ptypes.UnsetBase) { + return nil, ErrInvalidPermission{caller.Address, "unset_base"} + } + if len(args) != 2*32 { + return nil, fmt.Errorf("unsetBase() takes two arguments (address, permFlag)") + } + addr, permNum := returnTwoArgs(args) + vmAcc := appState.GetAccount(addr) + if vmAcc == nil { + return nil, fmt.Errorf("Unknown account %X", addr) + } + permN := ptypes.PermFlag(Uint64FromWord256(permNum)) + if !ValidPermN(permN) { + return nil, ptypes.ErrInvalidPermission(permN) + } + if err = vmAcc.Permissions.Base.Unset(permN); err != nil { + return nil, err + } + appState.UpdateAccount(vmAcc) + dbg.Printf("snative.unsetBasePerm(0x%X, %b)\n", addr.Postfix(20), permN) + return permNum.Bytes(), nil +} + +func setGlobalPerm(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) { + if !HasPermission(appState, caller, ptypes.SetGlobal) { + return nil, ErrInvalidPermission{caller.Address, "set_global"} + } + if len(args) != 2*32 { + return nil, fmt.Errorf("setGlobal() takes two arguments (permFlag, permission value)") + } + permNum, perm := returnTwoArgs(args) + vmAcc := appState.GetAccount(ptypes.GlobalPermissionsAddress256) + if vmAcc == nil { + PanicSanity("cant find the global permissions account") + } + permN := ptypes.PermFlag(Uint64FromWord256(permNum)) + if !ValidPermN(permN) { + return nil, ptypes.ErrInvalidPermission(permN) + } + permV := !perm.IsZero() + if err = vmAcc.Permissions.Base.Set(permN, permV); err != nil { + return nil, err + } + appState.UpdateAccount(vmAcc) + dbg.Printf("snative.setGlobalPerm(%b, %v)\n", permN, permV) + return perm.Bytes(), nil +} + +func hasRole(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) { + if !HasPermission(appState, caller, ptypes.HasRole) { + return nil, ErrInvalidPermission{caller.Address, "has_role"} + } + if len(args) != 2*32 { + return nil, fmt.Errorf("hasRole() takes two arguments (address, role)") + } + addr, role := returnTwoArgs(args) + vmAcc := appState.GetAccount(addr) + if vmAcc == nil { + return nil, fmt.Errorf("Unknown account %X", addr) + } + roleS := string(role.Bytes()) + var permInt byte + if vmAcc.Permissions.HasRole(roleS) { + permInt = 0x1 + } else { + permInt = 0x0 + } + dbg.Printf("snative.hasRole(0x%X, %s) = %v\n", addr.Postfix(20), roleS, permInt > 0) + return LeftPadWord256([]byte{permInt}).Bytes(), nil +} + +func addRole(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) { + if !HasPermission(appState, caller, ptypes.AddRole) { + return nil, ErrInvalidPermission{caller.Address, "add_role"} + } + if len(args) != 2*32 { + return nil, fmt.Errorf("addRole() takes two arguments (address, role)") + } + addr, role := returnTwoArgs(args) + vmAcc := appState.GetAccount(addr) + if vmAcc == nil { + return nil, fmt.Errorf("Unknown account %X", addr) + } + roleS := string(role.Bytes()) + var permInt byte + if vmAcc.Permissions.AddRole(roleS) { + permInt = 0x1 + } else { + permInt = 0x0 + } + appState.UpdateAccount(vmAcc) + dbg.Printf("snative.addRole(0x%X, %s) = %v\n", addr.Postfix(20), roleS, permInt > 0) + return LeftPadWord256([]byte{permInt}).Bytes(), nil +} + +func rmRole(appState AppState, caller *Account, args []byte, gas *int64) (output []byte, err error) { + if !HasPermission(appState, caller, ptypes.RmRole) { + return nil, ErrInvalidPermission{caller.Address, "rm_role"} + } + if len(args) != 2*32 { + return nil, fmt.Errorf("rmRole() takes two arguments (address, role)") + } + addr, role := returnTwoArgs(args) + vmAcc := appState.GetAccount(addr) + if vmAcc == nil { + return nil, fmt.Errorf("Unknown account %X", addr) + } + roleS := string(role.Bytes()) + var permInt byte + if vmAcc.Permissions.RmRole(roleS) { + permInt = 0x1 + } else { + permInt = 0x0 + } + appState.UpdateAccount(vmAcc) + dbg.Printf("snative.rmRole(0x%X, %s) = %v\n", addr.Postfix(20), roleS, permInt > 0) + return LeftPadWord256([]byte{permInt}).Bytes(), nil +} + +//------------------------------------------------------------------------------------------------ +// Errors and utility funcs + +type ErrInvalidPermission struct { + Address Word256 + SNative string +} + +func (e ErrInvalidPermission) Error() string { + return fmt.Sprintf("Account %X does not have permission snative.%s", e.Address.Postfix(20), e.SNative) +} + +// Checks if a permission flag is valid (a known base chain or snative permission) +func ValidPermN(n ptypes.PermFlag) bool { + if n > ptypes.TopPermFlag { + return false + } + return true +} + +// CONTRACT: length has already been checked +func returnTwoArgs(args []byte) (a Word256, b Word256) { + copy(a[:], args[:32]) + copy(b[:], args[32:64]) + return +} + +// CONTRACT: length has already been checked +func returnThreeArgs(args []byte) (a Word256, b Word256, c Word256) { + copy(a[:], args[:32]) + copy(b[:], args[32:64]) + copy(c[:], args[64:96]) + return +} diff --git a/evm/stack.go b/evm/stack.go new file mode 100644 index 0000000000000000000000000000000000000000..979aba2e3ceb1a8d3f61bf4d7935094619579ed8 --- /dev/null +++ b/evm/stack.go @@ -0,0 +1,126 @@ +package vm + +import ( + "fmt" + . "github.com/tendermint/go-common" +) + +// Not goroutine safe +type Stack struct { + data []Word256 + ptr int + + gas *int64 + err *error +} + +func NewStack(capacity int, gas *int64, err *error) *Stack { + return &Stack{ + data: make([]Word256, capacity), + ptr: 0, + gas: gas, + err: err, + } +} + +func (st *Stack) useGas(gasToUse int64) { + if *st.gas > gasToUse { + *st.gas -= gasToUse + } else { + st.setErr(ErrInsufficientGas) + } +} + +func (st *Stack) setErr(err error) { + if *st.err == nil { + *st.err = err + } +} + +func (st *Stack) Push(d Word256) { + st.useGas(GasStackOp) + if st.ptr == cap(st.data) { + st.setErr(ErrDataStackOverflow) + return + } + st.data[st.ptr] = d + st.ptr++ +} + +// currently only called after Sha3 +func (st *Stack) PushBytes(bz []byte) { + if len(bz) != 32 { + PanicSanity("Invalid bytes size: expected 32") + } + st.Push(LeftPadWord256(bz)) +} + +func (st *Stack) Push64(i int64) { + st.Push(Int64ToWord256(i)) +} + +func (st *Stack) Pop() Word256 { + st.useGas(GasStackOp) + if st.ptr == 0 { + st.setErr(ErrDataStackUnderflow) + return Zero256 + } + st.ptr-- + return st.data[st.ptr] +} + +func (st *Stack) PopBytes() []byte { + return st.Pop().Bytes() +} + +func (st *Stack) Pop64() int64 { + d := st.Pop() + return Int64FromWord256(d) +} + +func (st *Stack) Len() int { + return st.ptr +} + +func (st *Stack) Swap(n int) { + st.useGas(GasStackOp) + if st.ptr < n { + st.setErr(ErrDataStackUnderflow) + return + } + st.data[st.ptr-n], st.data[st.ptr-1] = st.data[st.ptr-1], st.data[st.ptr-n] + return +} + +func (st *Stack) Dup(n int) { + st.useGas(GasStackOp) + if st.ptr < n { + st.setErr(ErrDataStackUnderflow) + return + } + st.Push(st.data[st.ptr-n]) + return +} + +// Not an opcode, costs no gas. +func (st *Stack) Peek() Word256 { + if st.ptr == 0 { + st.setErr(ErrDataStackUnderflow) + return Zero256 + } + return st.data[st.ptr-1] +} + +func (st *Stack) Print(n int) { + fmt.Println("### stack ###") + if st.ptr > 0 { + nn := MinInt(n, st.ptr) + for j, i := 0, st.ptr-1; i > st.ptr-1-nn; i-- { + fmt.Printf("%-3d %X\n", j, st.data[i]) + j += 1 + } + } else { + fmt.Println("-- empty --") + } + fmt.Println("#############") +} diff --git a/evm/test/fake_app_state.go b/evm/test/fake_app_state.go new file mode 100644 index 0000000000000000000000000000000000000000..9204218fcfe1b72107d359b975cb7c49e7046af5 --- /dev/null +++ b/evm/test/fake_app_state.go @@ -0,0 +1,79 @@ +package vm + +import ( + . "github.com/tendermint/go-common" + . "github.com/eris-ltd/eris-db/evm" + "github.com/eris-ltd/eris-db/evm/sha3" +) + +type FakeAppState struct { + accounts map[string]*Account + storage map[string]Word256 +} + +func (fas *FakeAppState) GetAccount(addr Word256) *Account { + account := fas.accounts[addr.String()] + return account +} + +func (fas *FakeAppState) UpdateAccount(account *Account) { + fas.accounts[account.Address.String()] = account +} + +func (fas *FakeAppState) RemoveAccount(account *Account) { + _, ok := fas.accounts[account.Address.String()] + if !ok { + panic(Fmt("Invalid account addr: %X", account.Address)) + } else { + // Remove account + delete(fas.accounts, account.Address.String()) + } +} + +func (fas *FakeAppState) CreateAccount(creator *Account) *Account { + addr := createAddress(creator) + account := fas.accounts[addr.String()] + if account == nil { + return &Account{ + Address: addr, + Balance: 0, + Code: nil, + Nonce: 0, + } + } else { + panic(Fmt("Invalid account addr: %X", addr)) + } +} + +func (fas *FakeAppState) GetStorage(addr Word256, key Word256) Word256 { + _, ok := fas.accounts[addr.String()] + if !ok { + panic(Fmt("Invalid account addr: %X", addr)) + } + + value, ok := fas.storage[addr.String()+key.String()] + if ok { + return value + } else { + return Zero256 + } +} + +func (fas *FakeAppState) SetStorage(addr Word256, key Word256, value Word256) { + _, ok := fas.accounts[addr.String()] + if !ok { + panic(Fmt("Invalid account addr: %X", addr)) + } + + fas.storage[addr.String()+key.String()] = value +} + +// Creates a 20 byte address and bumps the nonce. +func createAddress(creator *Account) Word256 { + nonce := creator.Nonce + creator.Nonce += 1 + temp := make([]byte, 32+8) + copy(temp, creator.Address[:]) + PutInt64BE(temp[32:], nonce) + return LeftPadWord256(sha3.Sha3(temp)[:20]) +} diff --git a/evm/test/log_event_test.go b/evm/test/log_event_test.go new file mode 100644 index 0000000000000000000000000000000000000000..d12ab5080b5248a36dec8237b5066b8a29fce1a2 --- /dev/null +++ b/evm/test/log_event_test.go @@ -0,0 +1,90 @@ +package vm + +import ( + "bytes" + "reflect" + "testing" + + . "github.com/tendermint/go-common" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/types" + . "github.com/eris-ltd/eris-db/evm" +) + +var expectedData = []byte{0x10} +var expectedHeight int64 = 0 +var expectedTopics = []Word256{ + Int64ToWord256(1), + Int64ToWord256(2), + Int64ToWord256(3), + Int64ToWord256(4)} + +// Tests logs and events. +func TestLog4(t *testing.T) { + + st := newAppState() + // Create accounts + account1 := &Account{ + Address: LeftPadWord256(makeBytes(20)), + } + account2 := &Account{ + Address: LeftPadWord256(makeBytes(20)), + } + st.accounts[account1.Address.String()] = account1 + st.accounts[account2.Address.String()] = account2 + + ourVm := NewVM(st, newParams(), Zero256, nil) + + eventSwitch := events.NewEventSwitch() + _, err := eventSwitch.Start() + if err != nil { + t.Errorf("Failed to start eventSwitch: %v", err) + } + eventID := types.EventStringLogEvent(account2.Address.Postfix(20)) + + doneChan := make(chan struct{}, 1) + + eventSwitch.AddListenerForEvent("test", eventID, func(event types.EventData) { + logEvent := event.(types.EventDataLog) + // No need to test address as this event would not happen if it wasn't correct + if !reflect.DeepEqual(logEvent.Topics, expectedTopics) { + t.Errorf("Event topics are wrong. Got: %v. Expected: %v", logEvent.Topics, expectedTopics) + } + if !bytes.Equal(logEvent.Data, expectedData) { + t.Errorf("Event data is wrong. Got: %s. Expected: %s", logEvent.Data, expectedData) + } + if logEvent.Height != expectedHeight { + t.Errorf("Event block height is wrong. Got: %d. Expected: %d", logEvent.Height, expectedHeight) + } + doneChan <- struct{}{} + }) + + ourVm.SetFireable(eventSwitch) + + var gas int64 = 100000 + + mstore8 := byte(MSTORE8) + push1 := byte(PUSH1) + log4 := byte(LOG4) + stop := byte(STOP) + + code := []byte{ + push1, 16, // data value + push1, 0, // memory slot + mstore8, + push1, 4, // topic 4 + push1, 3, // topic 3 + push1, 2, // topic 2 + push1, 1, // topic 1 + push1, 1, // size of data + push1, 0, // data starts at this offset + log4, + stop, + } + + _, err = ourVm.Call(account1, account2, code, []byte{}, 0, &gas) + <-doneChan + if err != nil { + t.Fatal(err) + } +} diff --git a/evm/test/vm_test.go b/evm/test/vm_test.go new file mode 100644 index 0000000000000000000000000000000000000000..6ea23aeb5a7b752e2ae5d961aa9155b150430c32 --- /dev/null +++ b/evm/test/vm_test.go @@ -0,0 +1,207 @@ +package vm + +import ( + "crypto/rand" + "encoding/hex" + "fmt" + "strings" + "testing" + "time" + + . "github.com/tendermint/go-common" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/types" + . "github.com/eris-ltd/eris-db/evm" + ptypes "github.com/eris-ltd/eris-db/permission/types" +) + +func newAppState() *FakeAppState { + fas := &FakeAppState{ + accounts: make(map[string]*Account), + storage: make(map[string]Word256), + } + // For default permissions + fas.accounts[ptypes.GlobalPermissionsAddress256.String()] = &Account{ + Permissions: ptypes.DefaultAccountPermissions, + } + return fas +} + +func newParams() Params { + return Params{ + BlockHeight: 0, + BlockHash: Zero256, + BlockTime: 0, + GasLimit: 0, + } +} + +func makeBytes(n int) []byte { + b := make([]byte, n) + rand.Read(b) + return b +} + +// Runs a basic loop +func TestVM(t *testing.T) { + ourVm := NewVM(newAppState(), newParams(), Zero256, nil) + + // Create accounts + account1 := &Account{ + Address: Int64ToWord256(100), + } + account2 := &Account{ + Address: Int64ToWord256(101), + } + + var gas int64 = 100000 + N := []byte{0x0f, 0x0f} + // Loop N times + code := []byte{0x60, 0x00, 0x60, 0x20, 0x52, 0x5B, byte(0x60 + len(N) - 1)} + code = append(code, N...) + code = append(code, []byte{0x60, 0x20, 0x51, 0x12, 0x15, 0x60, byte(0x1b + len(N)), 0x57, 0x60, 0x01, 0x60, 0x20, 0x51, 0x01, 0x60, 0x20, 0x52, 0x60, 0x05, 0x56, 0x5B}...) + start := time.Now() + output, err := ourVm.Call(account1, account2, code, []byte{}, 0, &gas) + fmt.Printf("Output: %v Error: %v\n", output, err) + fmt.Println("Call took:", time.Since(start)) + if err != nil { + t.Fatal(err) + } +} + +// Tests the code for a subcurrency contract compiled by serpent +func TestSubcurrency(t *testing.T) { + st := newAppState() + // Create accounts + account1 := &Account{ + Address: LeftPadWord256(makeBytes(20)), + } + account2 := &Account{ + Address: LeftPadWord256(makeBytes(20)), + } + st.accounts[account1.Address.String()] = account1 + st.accounts[account2.Address.String()] = account2 + + ourVm := NewVM(st, newParams(), Zero256, nil) + + var gas int64 = 1000 + code_parts := []string{"620f42403355", + "7c0100000000000000000000000000000000000000000000000000000000", + "600035046315cf268481141561004657", + "6004356040526040515460605260206060f35b63693200ce81141561008757", + "60043560805260243560a052335460c0523360e05260a05160c05112151561008657", + "60a05160c0510360e0515560a0516080515401608051555b5b505b6000f3"} + code, _ := hex.DecodeString(strings.Join(code_parts, "")) + fmt.Printf("Code: %x\n", code) + data, _ := hex.DecodeString("693200CE0000000000000000000000004B4363CDE27C2EB05E66357DB05BC5C88F850C1A0000000000000000000000000000000000000000000000000000000000000005") + output, err := ourVm.Call(account1, account2, code, data, 0, &gas) + fmt.Printf("Output: %v Error: %v\n", output, err) + if err != nil { + t.Fatal(err) + } +} + +// Test sending tokens from a contract to another account +func TestSendCall(t *testing.T) { + fakeAppState := newAppState() + ourVm := NewVM(fakeAppState, newParams(), Zero256, nil) + + // Create accounts + account1 := &Account{ + Address: Int64ToWord256(100), + } + account2 := &Account{ + Address: Int64ToWord256(101), + } + account3 := &Account{ + Address: Int64ToWord256(102), + } + + // account1 will call account2 which will trigger CALL opcode to account3 + addr := account3.Address.Postfix(20) + contractCode := callContractCode(addr) + + //---------------------------------------------- + // account2 has insufficient balance, should fail + fmt.Println("Should fail with insufficient balance") + + exception := runVMWaitEvents(t, ourVm, account1, account2, addr, contractCode, 1000) + if exception == "" { + t.Fatal("Expected exception") + } + + //---------------------------------------------- + // give account2 sufficient balance, should pass + + account2.Balance = 100000 + exception = runVMWaitEvents(t, ourVm, account1, account2, addr, contractCode, 1000) + if exception != "" { + t.Fatal("Unexpected exception", exception) + } + + //---------------------------------------------- + // insufficient gas, should fail + fmt.Println("Should fail with insufficient gas") + + account2.Balance = 100000 + exception = runVMWaitEvents(t, ourVm, account1, account2, addr, contractCode, 100) + if exception == "" { + t.Fatal("Expected exception") + } +} + +// subscribes to an AccCall, runs the vm, returns the exception +func runVMWaitEvents(t *testing.T, ourVm *VM, caller, callee *Account, subscribeAddr, contractCode []byte, gas int64) string { + // we need to catch the event from the CALL to check for exceptions + evsw := events.NewEventSwitch() + evsw.Start() + ch := make(chan interface{}) + fmt.Printf("subscribe to %x\n", subscribeAddr) + evsw.AddListenerForEvent("test", types.EventStringAccCall(subscribeAddr), func(msg types.EventData) { + ch <- msg + }) + evc := events.NewEventCache(evsw) + ourVm.SetFireable(evc) + go func() { + start := time.Now() + output, err := ourVm.Call(caller, callee, contractCode, []byte{}, 0, &gas) + fmt.Printf("Output: %v Error: %v\n", output, err) + fmt.Println("Call took:", time.Since(start)) + if err != nil { + ch <- err.Error() + } + evc.Flush() + }() + msg := <-ch + switch ev := msg.(type) { + case types.EventDataTx: + return ev.Exception + case types.EventDataCall: + return ev.Exception + case string: + return ev + } + return "" +} + +// this is code to call another contract (hardcoded as addr) +func callContractCode(addr []byte) []byte { + gas1, gas2 := byte(0x1), byte(0x1) + value := byte(0x69) + inOff, inSize := byte(0x0), byte(0x0) // no call data + retOff, retSize := byte(0x0), byte(0x20) + // this is the code we want to run (send funds to an account and return) + contractCode := []byte{0x60, retSize, 0x60, retOff, 0x60, inSize, 0x60, inOff, 0x60, value, 0x73} + contractCode = append(contractCode, addr...) + contractCode = append(contractCode, []byte{0x61, gas1, gas2, 0xf1, 0x60, 0x20, 0x60, 0x0, 0xf3}...) + return contractCode +} + +/* + // infinite loop + code := []byte{0x5B, 0x60, 0x00, 0x56} + // mstore + code := []byte{0x60, 0x00, 0x60, 0x20} + // mstore, mload + code := []byte{0x60, 0x01, 0x60, 0x20, 0x52, 0x60, 0x20, 0x51} +*/ diff --git a/evm/types.go b/evm/types.go new file mode 100644 index 0000000000000000000000000000000000000000..5588d996161f338f6d6b3b8e928b74d28734d0dd --- /dev/null +++ b/evm/types.go @@ -0,0 +1,49 @@ +package vm + +import ( + . "github.com/tendermint/go-common" + ptypes "github.com/eris-ltd/eris-db/permission/types" +) + +const ( + defaultDataStackCapacity = 10 +) + +type Account struct { + Address Word256 + Balance int64 + Code []byte + Nonce int64 + Other interface{} // For holding all other data. + + Permissions ptypes.AccountPermissions +} + +func (acc *Account) String() string { + if acc == nil { + return "nil-VMAccount" + } + return Fmt("VMAccount{%X B:%v C:%X N:%v}", + acc.Address, acc.Balance, acc.Code, acc.Nonce) +} + +type AppState interface { + + // Accounts + GetAccount(addr Word256) *Account + UpdateAccount(*Account) + RemoveAccount(*Account) + CreateAccount(*Account) *Account + + // Storage + GetStorage(Word256, Word256) Word256 + SetStorage(Word256, Word256, Word256) // Setting to Zero is deleting. + +} + +type Params struct { + BlockHeight int64 + BlockHash Word256 + BlockTime int64 + GasLimit int64 +} diff --git a/evm/vm.go b/evm/vm.go new file mode 100644 index 0000000000000000000000000000000000000000..ad911e68bdf44db152144dc407d876157f95d615 --- /dev/null +++ b/evm/vm.go @@ -0,0 +1,918 @@ +package vm + +import ( + "bytes" + "errors" + "fmt" + "math/big" + + . "github.com/tendermint/go-common" + "github.com/tendermint/tendermint/events" + "github.com/eris-ltd/eris-db/evm/sha3" + ptypes "github.com/eris-ltd/eris-db/permission/types" + types "github.com/eris-ltd/eris-db/txs" +) + +var ( + ErrUnknownAddress = errors.New("Unknown address") + ErrInsufficientBalance = errors.New("Insufficient balance") + ErrInvalidJumpDest = errors.New("Invalid jump dest") + ErrInsufficientGas = errors.New("Insuffient gas") + ErrMemoryOutOfBounds = errors.New("Memory out of bounds") + ErrCodeOutOfBounds = errors.New("Code out of bounds") + ErrInputOutOfBounds = errors.New("Input out of bounds") + ErrCallStackOverflow = errors.New("Call stack overflow") + ErrCallStackUnderflow = errors.New("Call stack underflow") + ErrDataStackOverflow = errors.New("Data stack overflow") + ErrDataStackUnderflow = errors.New("Data stack underflow") + ErrInvalidContract = errors.New("Invalid contract") +) + +type ErrPermission struct { + typ string +} + +func (err ErrPermission) Error() string { + return fmt.Sprintf("Contract does not have permission to %s", err.typ) +} + +type Debug bool + +const ( + dataStackCapacity = 1024 + callStackCapacity = 100 // TODO ensure usage. + memoryCapacity = 1024 * 1024 // 1 MB + dbg Debug = true +) + +func (d Debug) Printf(s string, a ...interface{}) { + if d { + fmt.Printf(s, a...) + } +} + +type VM struct { + appState AppState + params Params + origin Word256 + txid []byte + + callDepth int + + evc events.Fireable +} + +func NewVM(appState AppState, params Params, origin Word256, txid []byte) *VM { + return &VM{ + appState: appState, + params: params, + origin: origin, + callDepth: 0, + txid: txid, + } +} + +// satisfies events.Eventable +func (vm *VM) SetFireable(evc events.Fireable) { + vm.evc = evc +} + +// CONTRACT: it is the duty of the contract writer to call known permissions +// we do not convey if a permission is not set +// (unlike in state/execution, where we guarantee HasPermission is called +// on known permissions and panics else) +// If the perm is not defined in the acc nor set by default in GlobalPermissions, +// prints a log warning and returns false. +func HasPermission(appState AppState, acc *Account, perm ptypes.PermFlag) bool { + v, err := acc.Permissions.Base.Get(perm) + if _, ok := err.(ptypes.ErrValueNotSet); ok { + if appState == nil { + log.Warn(Fmt("\n\n***** Unknown permission %b! ********\n\n", perm)) + return false + } + return HasPermission(nil, appState.GetAccount(ptypes.GlobalPermissionsAddress256), perm) + } + return v +} + +func (vm *VM) fireCallEvent(exception *string, output *[]byte, caller, callee *Account, input []byte, value int64, gas *int64) { + // fire the post call event (including exception if applicable) + if vm.evc != nil { + vm.evc.FireEvent(types.EventStringAccCall(callee.Address.Postfix(20)), types.EventDataCall{ + &types.CallData{caller.Address.Postfix(20), callee.Address.Postfix(20), input, value, *gas}, + vm.origin.Postfix(20), + vm.txid, + *output, + *exception, + }) + } +} + +// CONTRACT appState is aware of caller and callee, so we can just mutate them. +// value: To be transferred from caller to callee. Refunded upon error. +// gas: Available gas. No refunds for gas. +// code: May be nil, since the CALL opcode may be used to send value from contracts to accounts +func (vm *VM) Call(caller, callee *Account, code, input []byte, value int64, gas *int64) (output []byte, err error) { + + exception := new(string) + // fire the post call event (including exception if applicable) + defer vm.fireCallEvent(exception, &output, caller, callee, input, value, gas) + + if err = transfer(caller, callee, value); err != nil { + *exception = err.Error() + return + } + + if len(code) > 0 { + vm.callDepth += 1 + output, err = vm.call(caller, callee, code, input, value, gas) + vm.callDepth -= 1 + if err != nil { + *exception = err.Error() + err := transfer(callee, caller, value) + if err != nil { + // data has been corrupted in ram + PanicCrisis("Could not return value to caller") + } + } + } + + return +} + +// Try to deduct gasToUse from gasLeft. If ok return false, otherwise +// set err and return true. +func useGasNegative(gasLeft *int64, gasToUse int64, err *error) bool { + if *gasLeft >= gasToUse { + *gasLeft -= gasToUse + return false + } else if *err == nil { + *err = ErrInsufficientGas + } + return true +} + +// Just like Call() but does not transfer 'value' or modify the callDepth. +func (vm *VM) call(caller, callee *Account, code, input []byte, value int64, gas *int64) (output []byte, err error) { + dbg.Printf("(%d) (%X) %X (code=%d) gas: %v (d) %X\n", vm.callDepth, caller.Address[:4], callee.Address, len(callee.Code), *gas, input) + + var ( + pc int64 = 0 + stack = NewStack(dataStackCapacity, gas, &err) + memory = make([]byte, memoryCapacity) + ) + + for { + + // Use BaseOp gas. + if useGasNegative(gas, GasBaseOp, &err) { + return nil, err + } + + var op = codeGetOp(code, pc) + dbg.Printf("(pc) %-3d (op) %-14s (st) %-4d ", pc, op.String(), stack.Len()) + + switch op { + + case ADD: // 0x01 + x, y := stack.Pop(), stack.Pop() + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + sum := new(big.Int).Add(xb, yb) + res := LeftPadWord256(U256(sum).Bytes()) + stack.Push(res) + dbg.Printf(" %v + %v = %v (%X)\n", xb, yb, sum, res) + + case MUL: // 0x02 + x, y := stack.Pop(), stack.Pop() + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + prod := new(big.Int).Mul(xb, yb) + res := LeftPadWord256(U256(prod).Bytes()) + stack.Push(res) + dbg.Printf(" %v * %v = %v (%X)\n", xb, yb, prod, res) + + case SUB: // 0x03 + x, y := stack.Pop(), stack.Pop() + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + diff := new(big.Int).Sub(xb, yb) + res := LeftPadWord256(U256(diff).Bytes()) + stack.Push(res) + dbg.Printf(" %v - %v = %v (%X)\n", xb, yb, diff, res) + + case DIV: // 0x04 + x, y := stack.Pop(), stack.Pop() + if y.IsZero() { + stack.Push(Zero256) + dbg.Printf(" %x / %x = %v\n", x, y, 0) + } else { + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + div := new(big.Int).Div(xb, yb) + res := LeftPadWord256(U256(div).Bytes()) + stack.Push(res) + dbg.Printf(" %v / %v = %v (%X)\n", xb, yb, div, res) + } + + case SDIV: // 0x05 + x, y := stack.Pop(), stack.Pop() + if y.IsZero() { + stack.Push(Zero256) + dbg.Printf(" %x / %x = %v\n", x, y, 0) + } else { + xb := S256(new(big.Int).SetBytes(x[:])) + yb := S256(new(big.Int).SetBytes(y[:])) + div := new(big.Int).Div(xb, yb) + res := LeftPadWord256(U256(div).Bytes()) + stack.Push(res) + dbg.Printf(" %v / %v = %v (%X)\n", xb, yb, div, res) + } + + case MOD: // 0x06 + x, y := stack.Pop(), stack.Pop() + if y.IsZero() { + stack.Push(Zero256) + dbg.Printf(" %v %% %v = %v\n", x, y, 0) + } else { + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + mod := new(big.Int).Mod(xb, yb) + res := LeftPadWord256(U256(mod).Bytes()) + stack.Push(res) + dbg.Printf(" %v %% %v = %v (%X)\n", xb, yb, mod, res) + } + + case SMOD: // 0x07 + x, y := stack.Pop(), stack.Pop() + if y.IsZero() { + stack.Push(Zero256) + dbg.Printf(" %v %% %v = %v\n", x, y, 0) + } else { + xb := S256(new(big.Int).SetBytes(x[:])) + yb := S256(new(big.Int).SetBytes(y[:])) + mod := new(big.Int).Mod(xb, yb) + res := LeftPadWord256(U256(mod).Bytes()) + stack.Push(res) + dbg.Printf(" %v %% %v = %v (%X)\n", xb, yb, mod, res) + } + + case ADDMOD: // 0x08 + x, y, z := stack.Pop(), stack.Pop(), stack.Pop() + if z.IsZero() { + stack.Push(Zero256) + dbg.Printf(" %v %% %v = %v\n", x, y, 0) + } else { + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + zb := new(big.Int).SetBytes(z[:]) + add := new(big.Int).Add(xb, yb) + mod := new(big.Int).Mod(add, zb) + res := LeftPadWord256(U256(mod).Bytes()) + stack.Push(res) + dbg.Printf(" %v + %v %% %v = %v (%X)\n", + xb, yb, zb, mod, res) + } + + case MULMOD: // 0x09 + x, y, z := stack.Pop(), stack.Pop(), stack.Pop() + if z.IsZero() { + stack.Push(Zero256) + dbg.Printf(" %v %% %v = %v\n", x, y, 0) + } else { + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + zb := new(big.Int).SetBytes(z[:]) + mul := new(big.Int).Mul(xb, yb) + mod := new(big.Int).Mod(mul, zb) + res := LeftPadWord256(U256(mod).Bytes()) + stack.Push(res) + dbg.Printf(" %v * %v %% %v = %v (%X)\n", + xb, yb, zb, mod, res) + } + + case EXP: // 0x0A + x, y := stack.Pop(), stack.Pop() + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + pow := new(big.Int).Exp(xb, yb, big.NewInt(0)) + res := LeftPadWord256(U256(pow).Bytes()) + stack.Push(res) + dbg.Printf(" %v ** %v = %v (%X)\n", xb, yb, pow, res) + + case SIGNEXTEND: // 0x0B + back := stack.Pop() + backb := new(big.Int).SetBytes(back[:]) + if backb.Cmp(big.NewInt(31)) < 0 { + bit := uint(backb.Uint64()*8 + 7) + num := stack.Pop() + numb := new(big.Int).SetBytes(num[:]) + mask := new(big.Int).Lsh(big.NewInt(1), bit) + mask.Sub(mask, big.NewInt(1)) + if numb.Bit(int(bit)) == 1 { + numb.Or(numb, mask.Not(mask)) + } else { + numb.Add(numb, mask) + } + res := LeftPadWord256(U256(numb).Bytes()) + dbg.Printf(" = %v (%X)", numb, res) + stack.Push(res) + } + + case LT: // 0x10 + x, y := stack.Pop(), stack.Pop() + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + if xb.Cmp(yb) < 0 { + stack.Push64(1) + dbg.Printf(" %v < %v = %v\n", xb, yb, 1) + } else { + stack.Push(Zero256) + dbg.Printf(" %v < %v = %v\n", xb, yb, 0) + } + + case GT: // 0x11 + x, y := stack.Pop(), stack.Pop() + xb := new(big.Int).SetBytes(x[:]) + yb := new(big.Int).SetBytes(y[:]) + if xb.Cmp(yb) > 0 { + stack.Push64(1) + dbg.Printf(" %v > %v = %v\n", xb, yb, 1) + } else { + stack.Push(Zero256) + dbg.Printf(" %v > %v = %v\n", xb, yb, 0) + } + + case SLT: // 0x12 + x, y := stack.Pop(), stack.Pop() + xb := S256(new(big.Int).SetBytes(x[:])) + yb := S256(new(big.Int).SetBytes(y[:])) + if xb.Cmp(yb) < 0 { + stack.Push64(1) + dbg.Printf(" %v < %v = %v\n", xb, yb, 1) + } else { + stack.Push(Zero256) + dbg.Printf(" %v < %v = %v\n", xb, yb, 0) + } + + case SGT: // 0x13 + x, y := stack.Pop(), stack.Pop() + xb := S256(new(big.Int).SetBytes(x[:])) + yb := S256(new(big.Int).SetBytes(y[:])) + if xb.Cmp(yb) > 0 { + stack.Push64(1) + dbg.Printf(" %v > %v = %v\n", xb, yb, 1) + } else { + stack.Push(Zero256) + dbg.Printf(" %v > %v = %v\n", xb, yb, 0) + } + + case EQ: // 0x14 + x, y := stack.Pop(), stack.Pop() + if bytes.Equal(x[:], y[:]) { + stack.Push64(1) + dbg.Printf(" %X == %X = %v\n", x, y, 1) + } else { + stack.Push(Zero256) + dbg.Printf(" %X == %X = %v\n", x, y, 0) + } + + case ISZERO: // 0x15 + x := stack.Pop() + if x.IsZero() { + stack.Push64(1) + dbg.Printf(" %v == 0 = %v\n", x, 1) + } else { + stack.Push(Zero256) + dbg.Printf(" %v == 0 = %v\n", x, 0) + } + + case AND: // 0x16 + x, y := stack.Pop(), stack.Pop() + z := [32]byte{} + for i := 0; i < 32; i++ { + z[i] = x[i] & y[i] + } + stack.Push(z) + dbg.Printf(" %X & %X = %X\n", x, y, z) + + case OR: // 0x17 + x, y := stack.Pop(), stack.Pop() + z := [32]byte{} + for i := 0; i < 32; i++ { + z[i] = x[i] | y[i] + } + stack.Push(z) + dbg.Printf(" %X | %X = %X\n", x, y, z) + + case XOR: // 0x18 + x, y := stack.Pop(), stack.Pop() + z := [32]byte{} + for i := 0; i < 32; i++ { + z[i] = x[i] ^ y[i] + } + stack.Push(z) + dbg.Printf(" %X ^ %X = %X\n", x, y, z) + + case NOT: // 0x19 + x := stack.Pop() + z := [32]byte{} + for i := 0; i < 32; i++ { + z[i] = ^x[i] + } + stack.Push(z) + dbg.Printf(" !%X = %X\n", x, z) + + case BYTE: // 0x1A + idx, val := stack.Pop64(), stack.Pop() + res := byte(0) + if idx < 32 { + res = val[idx] + } + stack.Push64(int64(res)) + dbg.Printf(" => 0x%X\n", res) + + case SHA3: // 0x20 + if useGasNegative(gas, GasSha3, &err) { + return nil, err + } + offset, size := stack.Pop64(), stack.Pop64() + data, ok := subslice(memory, offset, size) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + data = sha3.Sha3(data) + stack.PushBytes(data) + dbg.Printf(" => (%v) %X\n", size, data) + + case ADDRESS: // 0x30 + stack.Push(callee.Address) + dbg.Printf(" => %X\n", callee.Address) + + case BALANCE: // 0x31 + addr := stack.Pop() + if useGasNegative(gas, GasGetAccount, &err) { + return nil, err + } + acc := vm.appState.GetAccount(addr) + if acc == nil { + return nil, firstErr(err, ErrUnknownAddress) + } + balance := acc.Balance + stack.Push64(balance) + dbg.Printf(" => %v (%X)\n", balance, addr) + + case ORIGIN: // 0x32 + stack.Push(vm.origin) + dbg.Printf(" => %X\n", vm.origin) + + case CALLER: // 0x33 + stack.Push(caller.Address) + dbg.Printf(" => %X\n", caller.Address) + + case CALLVALUE: // 0x34 + stack.Push64(value) + dbg.Printf(" => %v\n", value) + + case CALLDATALOAD: // 0x35 + offset := stack.Pop64() + data, ok := subslice(input, offset, 32) + if !ok { + return nil, firstErr(err, ErrInputOutOfBounds) + } + res := LeftPadWord256(data) + stack.Push(res) + dbg.Printf(" => 0x%X\n", res) + + case CALLDATASIZE: // 0x36 + stack.Push64(int64(len(input))) + dbg.Printf(" => %d\n", len(input)) + + case CALLDATACOPY: // 0x37 + memOff := stack.Pop64() + inputOff := stack.Pop64() + length := stack.Pop64() + data, ok := subslice(input, inputOff, length) + if !ok { + return nil, firstErr(err, ErrInputOutOfBounds) + } + dest, ok := subslice(memory, memOff, length) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + copy(dest, data) + dbg.Printf(" => [%v, %v, %v] %X\n", memOff, inputOff, length, data) + + case CODESIZE: // 0x38 + l := int64(len(code)) + stack.Push64(l) + dbg.Printf(" => %d\n", l) + + case CODECOPY: // 0x39 + memOff := stack.Pop64() + codeOff := stack.Pop64() + length := stack.Pop64() + data, ok := subslice(code, codeOff, length) + if !ok { + return nil, firstErr(err, ErrCodeOutOfBounds) + } + dest, ok := subslice(memory, memOff, length) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + copy(dest, data) + dbg.Printf(" => [%v, %v, %v] %X\n", memOff, codeOff, length, data) + + case GASPRICE_DEPRECATED: // 0x3A + stack.Push(Zero256) + dbg.Printf(" => %X (GASPRICE IS DEPRECATED)\n") + + case EXTCODESIZE: // 0x3B + addr := stack.Pop() + if useGasNegative(gas, GasGetAccount, &err) { + return nil, err + } + acc := vm.appState.GetAccount(addr) + if acc == nil { + return nil, firstErr(err, ErrUnknownAddress) + } + code := acc.Code + l := int64(len(code)) + stack.Push64(l) + dbg.Printf(" => %d\n", l) + + case EXTCODECOPY: // 0x3C + addr := stack.Pop() + if useGasNegative(gas, GasGetAccount, &err) { + return nil, err + } + acc := vm.appState.GetAccount(addr) + if acc == nil { + return nil, firstErr(err, ErrUnknownAddress) + } + code := acc.Code + memOff := stack.Pop64() + codeOff := stack.Pop64() + length := stack.Pop64() + data, ok := subslice(code, codeOff, length) + if !ok { + return nil, firstErr(err, ErrCodeOutOfBounds) + } + dest, ok := subslice(memory, memOff, length) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + copy(dest, data) + dbg.Printf(" => [%v, %v, %v] %X\n", memOff, codeOff, length, data) + + case BLOCKHASH: // 0x40 + stack.Push(Zero256) + dbg.Printf(" => 0x%X (NOT SUPPORTED)\n", stack.Peek().Bytes()) + + case COINBASE: // 0x41 + stack.Push(Zero256) + dbg.Printf(" => 0x%X (NOT SUPPORTED)\n", stack.Peek().Bytes()) + + case TIMESTAMP: // 0x42 + time := vm.params.BlockTime + stack.Push64(int64(time)) + dbg.Printf(" => 0x%X\n", time) + + case BLOCKHEIGHT: // 0x43 + number := int64(vm.params.BlockHeight) + stack.Push64(number) + dbg.Printf(" => 0x%X\n", number) + + case GASLIMIT: // 0x45 + stack.Push64(vm.params.GasLimit) + dbg.Printf(" => %v\n", vm.params.GasLimit) + + case POP: // 0x50 + popped := stack.Pop() + dbg.Printf(" => 0x%X\n", popped) + + case MLOAD: // 0x51 + offset := stack.Pop64() + data, ok := subslice(memory, offset, 32) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + stack.Push(LeftPadWord256(data)) + dbg.Printf(" => 0x%X\n", data) + + case MSTORE: // 0x52 + offset, data := stack.Pop64(), stack.Pop() + dest, ok := subslice(memory, offset, 32) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + copy(dest, data[:]) + dbg.Printf(" => 0x%X\n", data) + + case MSTORE8: // 0x53 + offset, val := stack.Pop64(), byte(stack.Pop64()&0xFF) + if len(memory) <= int(offset) { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + memory[offset] = val + dbg.Printf(" => [%v] 0x%X\n", offset, val) + + case SLOAD: // 0x54 + loc := stack.Pop() + data := vm.appState.GetStorage(callee.Address, loc) + stack.Push(data) + dbg.Printf(" {0x%X : 0x%X}\n", loc, data) + + case SSTORE: // 0x55 + loc, data := stack.Pop(), stack.Pop() + if useGasNegative(gas, GasStorageUpdate, &err) { + return nil, err + } + vm.appState.SetStorage(callee.Address, loc, data) + dbg.Printf(" {0x%X : 0x%X}\n", loc, data) + + case JUMP: // 0x56 + err = jump(code, stack.Pop64(), &pc) + continue + + case JUMPI: // 0x57 + pos, cond := stack.Pop64(), stack.Pop() + if !cond.IsZero() { + err = jump(code, pos, &pc) + continue + } + dbg.Printf(" ~> false\n") + + case PC: // 0x58 + stack.Push64(pc) + + case MSIZE: // 0x59 + stack.Push64(int64(len(memory))) + + case GAS: // 0x5A + stack.Push64(*gas) + dbg.Printf(" => %X\n", *gas) + + case JUMPDEST: // 0x5B + dbg.Printf("\n") + // Do nothing + + case PUSH1, PUSH2, PUSH3, PUSH4, PUSH5, PUSH6, PUSH7, PUSH8, PUSH9, PUSH10, PUSH11, PUSH12, PUSH13, PUSH14, PUSH15, PUSH16, PUSH17, PUSH18, PUSH19, PUSH20, PUSH21, PUSH22, PUSH23, PUSH24, PUSH25, PUSH26, PUSH27, PUSH28, PUSH29, PUSH30, PUSH31, PUSH32: + a := int64(op - PUSH1 + 1) + codeSegment, ok := subslice(code, pc+1, a) + if !ok { + return nil, firstErr(err, ErrCodeOutOfBounds) + } + res := LeftPadWord256(codeSegment) + stack.Push(res) + pc += a + dbg.Printf(" => 0x%X\n", res) + //stack.Print(10) + + case DUP1, DUP2, DUP3, DUP4, DUP5, DUP6, DUP7, DUP8, DUP9, DUP10, DUP11, DUP12, DUP13, DUP14, DUP15, DUP16: + n := int(op - DUP1 + 1) + stack.Dup(n) + dbg.Printf(" => [%d] 0x%X\n", n, stack.Peek().Bytes()) + + case SWAP1, SWAP2, SWAP3, SWAP4, SWAP5, SWAP6, SWAP7, SWAP8, SWAP9, SWAP10, SWAP11, SWAP12, SWAP13, SWAP14, SWAP15, SWAP16: + n := int(op - SWAP1 + 2) + stack.Swap(n) + dbg.Printf(" => [%d] %X\n", n, stack.Peek()) + //stack.Print(10) + + case LOG0, LOG1, LOG2, LOG3, LOG4: + n := int(op - LOG0) + topics := make([]Word256, n) + offset, size := stack.Pop64(), stack.Pop64() + for i := 0; i < n; i++ { + topics[i] = stack.Pop() + } + data, ok := subslice(memory, offset, size) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + if vm.evc != nil { + eventID := types.EventStringLogEvent(callee.Address.Postfix(20)) + fmt.Printf("eventID: %s\n", eventID) + log := types.EventDataLog{ + callee.Address, + topics, + data, + vm.params.BlockHeight, + } + vm.evc.FireEvent(eventID, log) + } + dbg.Printf(" => T:%X D:%X\n", topics, data) + + case CREATE: // 0xF0 + if !HasPermission(vm.appState, callee, ptypes.CreateContract) { + return nil, ErrPermission{"create_contract"} + } + contractValue := stack.Pop64() + offset, size := stack.Pop64(), stack.Pop64() + input, ok := subslice(memory, offset, size) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + + // Check balance + if callee.Balance < contractValue { + return nil, firstErr(err, ErrInsufficientBalance) + } + + // TODO charge for gas to create account _ the code length * GasCreateByte + + newAccount := vm.appState.CreateAccount(callee) + // Run the input to get the contract code. + ret, err_ := vm.Call(callee, newAccount, input, input, contractValue, gas) + if err_ != nil { + stack.Push(Zero256) + } else { + newAccount.Code = ret // Set the code + stack.Push(newAccount.Address) + } + + case CALL, CALLCODE: // 0xF1, 0xF2 + if !HasPermission(vm.appState, callee, ptypes.Call) { + return nil, ErrPermission{"call"} + } + gasLimit := stack.Pop64() + addr, value := stack.Pop(), stack.Pop64() + inOffset, inSize := stack.Pop64(), stack.Pop64() // inputs + retOffset, retSize := stack.Pop64(), stack.Pop64() // outputs + dbg.Printf(" => %X\n", addr) + + // Get the arguments from the memory + args, ok := subslice(memory, inOffset, inSize) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + + // Ensure that gasLimit is reasonable + if *gas < gasLimit { + return nil, firstErr(err, ErrInsufficientGas) + } else { + *gas -= gasLimit + // NOTE: we will return any used gas later. + } + + // Begin execution + var ret []byte + var err error + if nativeContract := registeredNativeContracts[addr]; nativeContract != nil { + // Native contract + ret, err = nativeContract(vm.appState, callee, args, &gasLimit) + + // for now we fire the Call event. maybe later we'll fire more particulars + var exception string + if err != nil { + exception = err.Error() + } + // NOTE: these fire call events and not particular events for eg name reg or permissions + vm.fireCallEvent(&exception, &ret, callee, &Account{Address: addr}, args, value, gas) + } else { + // EVM contract + if useGasNegative(gas, GasGetAccount, &err) { + return nil, err + } + acc := vm.appState.GetAccount(addr) + // since CALL is used also for sending funds, + // acc may not exist yet. This is an error for + // CALLCODE, but not for CALL, though I don't think + // ethereum actually cares + if op == CALLCODE { + if acc == nil { + return nil, firstErr(err, ErrUnknownAddress) + } + ret, err = vm.Call(callee, callee, acc.Code, args, value, gas) + } else { + if acc == nil { + // nil account means we're sending funds to a new account + if !HasPermission(vm.appState, caller, ptypes.CreateAccount) { + return nil, ErrPermission{"create_account"} + } + acc = &Account{Address: addr} + vm.appState.UpdateAccount(acc) + // send funds to new account + ret, err = vm.Call(callee, acc, acc.Code, args, value, gas) + } else { + // call standard contract + ret, err = vm.Call(callee, acc, acc.Code, args, value, gas) + } + } + } + + // Push result + if err != nil { + dbg.Printf("error on call: %s\n", err.Error()) + stack.Push(Zero256) + } else { + stack.Push(One256) + dest, ok := subslice(memory, retOffset, retSize) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + copy(dest, ret) + } + + // Handle remaining gas. + *gas += gasLimit + + dbg.Printf("resume %X (%v)\n", callee.Address, gas) + + case RETURN: // 0xF3 + offset, size := stack.Pop64(), stack.Pop64() + ret, ok := subslice(memory, offset, size) + if !ok { + return nil, firstErr(err, ErrMemoryOutOfBounds) + } + dbg.Printf(" => [%v, %v] (%d) 0x%X\n", offset, size, len(ret), ret) + return ret, nil + + case SUICIDE: // 0xFF + addr := stack.Pop() + if useGasNegative(gas, GasGetAccount, &err) { + return nil, err + } + // TODO if the receiver is , then make it the fee. (?) + // TODO: create account if doesn't exist (no reason not to) + receiver := vm.appState.GetAccount(addr) + if receiver == nil { + return nil, firstErr(err, ErrUnknownAddress) + } + balance := callee.Balance + receiver.Balance += balance + vm.appState.UpdateAccount(receiver) + vm.appState.RemoveAccount(callee) + dbg.Printf(" => (%X) %v\n", addr[:4], balance) + fallthrough + + case STOP: // 0x00 + return nil, nil + + default: + dbg.Printf("(pc) %-3v Invalid opcode %X\n", pc, op) + return nil, fmt.Errorf("Invalid opcode %X", op) + } + + pc++ + + } +} + +func subslice(data []byte, offset, length int64) (ret []byte, ok bool) { + size := int64(len(data)) + if size < offset { + return nil, false + } else if size < offset+length { + ret, ok = data[offset:], true + ret = RightPadBytes(ret, 32) + } else { + ret, ok = data[offset:offset+length], true + } + + return +} + +func rightMostBytes(data []byte, n int) []byte { + size := MinInt(len(data), n) + offset := len(data) - size + return data[offset:] +} + +func codeGetOp(code []byte, n int64) OpCode { + if int64(len(code)) <= n { + return OpCode(0) // stop + } else { + return OpCode(code[n]) + } +} + +func jump(code []byte, to int64, pc *int64) (err error) { + dest := codeGetOp(code, to) + if dest != JUMPDEST { + dbg.Printf(" ~> %v invalid jump dest %v\n", to, dest) + return ErrInvalidJumpDest + } + dbg.Printf(" ~> %v\n", to) + *pc = to + return nil +} + +func firstErr(errA, errB error) error { + if errA != nil { + return errA + } else { + return errB + } +} + +func transfer(from, to *Account, amount int64) error { + if from.Balance < amount { + return ErrInsufficientBalance + } else { + from.Balance -= amount + to.Balance += amount + return nil + } +} diff --git a/files/files_test.go b/files/files_test.go index bdfa44265a19b727a8ef9dad251632bcaec26f18..2d9cdc23ed1646f3acb242904015df3ba1418945 100644 --- a/files/files_test.go +++ b/files/files_test.go @@ -2,7 +2,7 @@ package files import ( "bytes" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" "os" "path" "testing" diff --git a/files/log.go b/files/log.go index 9067bf137b741db2a06094b0de429054bfcc493e..a18f6b6a6ec7420d469269b33832a2e5cc277a43 100644 --- a/files/log.go +++ b/files/log.go @@ -1,7 +1,7 @@ package files import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "eris/server/files") diff --git a/permission/types/errors.go b/permission/types/errors.go new file mode 100644 index 0000000000000000000000000000000000000000..4b1d7cb945a40bcc614546ea08587c6478c90c23 --- /dev/null +++ b/permission/types/errors.go @@ -0,0 +1,23 @@ +package types + +import ( + "fmt" +) + +//------------------------------------------------------------------------------------------------ +// Some errors + +// permission number out of bounds +type ErrInvalidPermission PermFlag + +func (e ErrInvalidPermission) Error() string { + return fmt.Sprintf("invalid permission %d", e) +} + +// set=false. This error should be caught and the global +// value fetched for the permission by the caller +type ErrValueNotSet PermFlag + +func (e ErrValueNotSet) Error() string { + return fmt.Sprintf("the value for permission %d is not set", e) +} diff --git a/permission/types/permissions.go b/permission/types/permissions.go new file mode 100644 index 0000000000000000000000000000000000000000..3c43ed17bd64c2600d0f6be5292e7d67690ed90e --- /dev/null +++ b/permission/types/permissions.go @@ -0,0 +1,238 @@ +package types + +import ( + "fmt" + . "github.com/tendermint/go-common" +) + +//------------------------------------------------------------------------------------------------ + +var ( + GlobalPermissionsAddress = Zero256[:20] + GlobalPermissionsAddress256 = Zero256 +) + +// A particular permission +type PermFlag uint64 + +// Base permission references are like unix (the index is already bit shifted) +const ( + // chain permissions + Root PermFlag = 1 << iota // 1 + Send // 2 + Call // 4 + CreateContract // 8 + CreateAccount // 16 + Bond // 32 + Name // 64 + + // moderator permissions + HasBase + SetBase + UnsetBase + SetGlobal + HasRole + AddRole + RmRole + + NumPermissions uint = 14 // NOTE Adjust this too. We can support upto 64 + + TopPermFlag PermFlag = 1 << (NumPermissions - 1) + AllPermFlags PermFlag = TopPermFlag | (TopPermFlag - 1) + DefaultPermFlags PermFlag = Send | Call | CreateContract | CreateAccount | Bond | Name | HasBase | HasRole +) + +var ( + ZeroBasePermissions = BasePermissions{0, 0} + ZeroAccountPermissions = AccountPermissions{ + Base: ZeroBasePermissions, + } + DefaultAccountPermissions = AccountPermissions{ + Base: BasePermissions{ + Perms: DefaultPermFlags, + SetBit: AllPermFlags, + }, + Roles: []string{}, + } +) + +//--------------------------------------------------------------------------------------------- + +// Base chain permissions struct +type BasePermissions struct { + // bit array with "has"/"doesn't have" for each permission + Perms PermFlag `json:"perms"` + + // bit array with "set"/"not set" for each permission (not-set should fall back to global) + SetBit PermFlag `json:"set"` +} + +// Get a permission value. ty should be a power of 2. +// ErrValueNotSet is returned if the permission's set bit is off, +// and should be caught by caller so the global permission can be fetched +func (p *BasePermissions) Get(ty PermFlag) (bool, error) { + if ty == 0 { + return false, ErrInvalidPermission(ty) + } + if p.SetBit&ty == 0 { + return false, ErrValueNotSet(ty) + } + return p.Perms&ty > 0, nil +} + +// Set a permission bit. Will set the permission's set bit to true. +func (p *BasePermissions) Set(ty PermFlag, value bool) error { + if ty == 0 { + return ErrInvalidPermission(ty) + } + p.SetBit |= ty + if value { + p.Perms |= ty + } else { + p.Perms &= ^ty + } + return nil +} + +// Set the permission's set bit to false +func (p *BasePermissions) Unset(ty PermFlag) error { + if ty == 0 { + return ErrInvalidPermission(ty) + } + p.SetBit &= ^ty + return nil +} + +// Check if the permission is set +func (p *BasePermissions) IsSet(ty PermFlag) bool { + if ty == 0 { + return false + } + return p.SetBit&ty > 0 +} + +func (p BasePermissions) String() string { + return fmt.Sprintf("Base: %b; Set: %b", p.Perms, p.SetBit) +} + +//--------------------------------------------------------------------------------------------- + +type AccountPermissions struct { + Base BasePermissions `json:"base"` + Roles []string `json:"roles"` +} + +// Returns true if the role is found +func (aP *AccountPermissions) HasRole(role string) bool { + role = string(LeftPadBytes([]byte(role), 32)) + for _, r := range aP.Roles { + if r == role { + return true + } + } + return false +} + +// Returns true if the role is added, and false if it already exists +func (aP *AccountPermissions) AddRole(role string) bool { + role = string(LeftPadBytes([]byte(role), 32)) + for _, r := range aP.Roles { + if r == role { + return false + } + } + aP.Roles = append(aP.Roles, role) + return true +} + +// Returns true if the role is removed, and false if it is not found +func (aP *AccountPermissions) RmRole(role string) bool { + role = string(LeftPadBytes([]byte(role), 32)) + for i, r := range aP.Roles { + if r == role { + post := []string{} + if len(aP.Roles) > i+1 { + post = aP.Roles[i+1:] + } + aP.Roles = append(aP.Roles[:i], post...) + return true + } + } + return false +} + +//-------------------------------------------------------------------------------- +// string utilities + +// PermFlagToString assumes the permFlag is valid, else returns "#-UNKNOWN-#" +func PermFlagToString(pf PermFlag) (perm string) { + switch pf { + case Root: + perm = "root" + case Send: + perm = "send" + case Call: + perm = "call" + case CreateContract: + perm = "create_contract" + case CreateAccount: + perm = "create_account" + case Bond: + perm = "bond" + case Name: + perm = "name" + case HasBase: + perm = "has_base" + case SetBase: + perm = "set_base" + case UnsetBase: + perm = "unset_base" + case SetGlobal: + perm = "set_global" + case HasRole: + perm = "has_role" + case AddRole: + perm = "add_role" + case RmRole: + perm = "rm_role" + default: + perm = "#-UNKNOWN-#" + } + return +} + +func PermStringToFlag(perm string) (pf PermFlag, err error) { + switch perm { + case "root": + pf = Root + case "send": + pf = Send + case "call": + pf = Call + case "create_contract": + pf = CreateContract + case "create_account": + pf = CreateAccount + case "bond": + pf = Bond + case "name": + pf = Name + case "has_base": + pf = HasBase + case "set_base": + pf = SetBase + case "unset_base": + pf = UnsetBase + case "set_global": + pf = SetGlobal + case "has_role": + pf = HasRole + case "add_role": + pf = AddRole + case "rm_role": + pf = RmRole + default: + err = fmt.Errorf("Unknown permission %s", perm) + } + return +} diff --git a/permission/types/snatives.go b/permission/types/snatives.go new file mode 100644 index 0000000000000000000000000000000000000000..57315ac937f1c6a58a97410d3f8fe5a0045b3dcd --- /dev/null +++ b/permission/types/snatives.go @@ -0,0 +1,102 @@ +package types + +import ( + "github.com/tendermint/go-wire" +) + +//--------------------------------------------------------------------------------------------------- +// PermissionsTx.PermArgs interface and argument encoding + +// Arguments are a registered interface in the PermissionsTx, +// so binary handles the arguments and each permission function gets a type-byte +// PermFlag() maps the type-byte to the permission +// The account sending the PermissionsTx must have this PermFlag set +type PermArgs interface { + PermFlag() PermFlag +} + +const ( + PermArgsTypeHasBase = byte(0x01) + PermArgsTypeSetBase = byte(0x02) + PermArgsTypeUnsetBase = byte(0x03) + PermArgsTypeSetGlobal = byte(0x04) + PermArgsTypeHasRole = byte(0x05) + PermArgsTypeAddRole = byte(0x06) + PermArgsTypeRmRole = byte(0x07) +) + +// for wire.readReflect +var _ = wire.RegisterInterface( + struct{ PermArgs }{}, + wire.ConcreteType{&HasBaseArgs{}, PermArgsTypeHasBase}, + wire.ConcreteType{&SetBaseArgs{}, PermArgsTypeSetBase}, + wire.ConcreteType{&UnsetBaseArgs{}, PermArgsTypeUnsetBase}, + wire.ConcreteType{&SetGlobalArgs{}, PermArgsTypeSetGlobal}, + wire.ConcreteType{&HasRoleArgs{}, PermArgsTypeHasRole}, + wire.ConcreteType{&AddRoleArgs{}, PermArgsTypeAddRole}, + wire.ConcreteType{&RmRoleArgs{}, PermArgsTypeRmRole}, +) + +type HasBaseArgs struct { + Address []byte `json:"address"` + Permission PermFlag `json:"permission"` +} + +func (*HasBaseArgs) PermFlag() PermFlag { + return HasBase +} + +type SetBaseArgs struct { + Address []byte `json:"address"` + Permission PermFlag `json:"permission"` + Value bool `json:"value"` +} + +func (*SetBaseArgs) PermFlag() PermFlag { + return SetBase +} + +type UnsetBaseArgs struct { + Address []byte `json:"address"` + Permission PermFlag `json:"permission"` +} + +func (*UnsetBaseArgs) PermFlag() PermFlag { + return UnsetBase +} + +type SetGlobalArgs struct { + Permission PermFlag `json:"permission"` + Value bool `json:"value"` +} + +func (*SetGlobalArgs) PermFlag() PermFlag { + return SetGlobal +} + +type HasRoleArgs struct { + Address []byte `json:"address"` + Role string `json:"role"` +} + +func (*HasRoleArgs) PermFlag() PermFlag { + return HasRole +} + +type AddRoleArgs struct { + Address []byte `json:"address"` + Role string `json:"role"` +} + +func (*AddRoleArgs) PermFlag() PermFlag { + return AddRole +} + +type RmRoleArgs struct { + Address []byte `json:"address"` + Role string `json:"role"` +} + +func (*RmRoleArgs) PermFlag() PermFlag { + return RmRole +} diff --git a/rpc/rpc_test.go b/rpc/rpc_test.go index a5debf5f78621a45beda0440ebcd95fbfe9bc8e6..bfafa4c2f9861f01192de0ad9b9aba05897d304d 100644 --- a/rpc/rpc_test.go +++ b/rpc/rpc_test.go @@ -1,7 +1,7 @@ package rpc import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" "testing" ) diff --git a/server/config.go b/server/config.go index bd84d4766feb99d6ce55051fcf17a90a788d945a..720dddcdc3558da42500a501031bca8b87d4abfc 100644 --- a/server/config.go +++ b/server/config.go @@ -1,7 +1,7 @@ package server import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/naoina/toml" + "github.com/naoina/toml" "github.com/eris-ltd/eris-db/files" ) diff --git a/server/log.go b/server/log.go index 09e6fbdad3708856ff9bfa14bc8e2236a99ba1eb..aacad33d92109b6353e54b91b438b3f2f7e746f3 100644 --- a/server/log.go +++ b/server/log.go @@ -1,7 +1,7 @@ package server import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" ) var log = log15.New("module", "eris/server") diff --git a/server/logging.go b/server/logging.go index 8b1ba444e437a70995ea69461d4d3c31e0500228..a5a70031af162f749641075bd1dd01e32087946e 100644 --- a/server/logging.go +++ b/server/logging.go @@ -2,7 +2,7 @@ package server import ( "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/tendermint/log15" "os" ) diff --git a/server/server.go b/server/server.go index f333b1ffcbc5336199b3135cea926de80784c759..e6bc35dd44ff41a187084a9f21002001172b3bda 100644 --- a/server/server.go +++ b/server/server.go @@ -3,9 +3,9 @@ package server import ( "crypto/tls" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - cors "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tommy351/gin-cors" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/gopkg.in/tylerb/graceful.v1" + "github.com/gin-gonic/gin" + cors "github.com/tommy351/gin-cors" + "gopkg.in/tylerb/graceful.v1" "net" "net/http" "time" diff --git a/server/server_test.go b/server/server_test.go index 55bfb66676a76ad2c610f67874cbb62b0196efcf..05d954b705fe5daf9980c7bd84d9b98dbb5c20b6 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -2,7 +2,7 @@ package server import ( //"fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" "testing" ) diff --git a/server/websocket.go b/server/websocket.go index 377de80ebe01471373abe35263580c1521f0eb1a..b37166fdd73c1ebf945830778079a20ceca0b95f 100644 --- a/server/websocket.go +++ b/server/websocket.go @@ -2,8 +2,8 @@ package server import ( "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gorilla/websocket" + "github.com/gin-gonic/gin" + "github.com/gorilla/websocket" "net/http" "sync" "time" diff --git a/state/block_cache.go b/state/block_cache.go new file mode 100644 index 0000000000000000000000000000000000000000..069ef8bca00c623b65dcb5ca40ea2267d1ae35dc --- /dev/null +++ b/state/block_cache.go @@ -0,0 +1,294 @@ +package state + +import ( + "bytes" + "sort" + + . "github.com/tendermint/go-common" + dbm "github.com/tendermint/go-db" + "github.com/tendermint/go-merkle" + "github.com/tendermint/go-wire" + + acm "github.com/eris-ltd/eris-db/account" + "github.com/eris-ltd/eris-db/txs" +) + +func makeStorage(db dbm.DB, root []byte) merkle.Tree { + storage := merkle.NewIAVLTree( + wire.BasicCodec, + wire.BasicCodec, + 1024, + db, + ) + storage.Load(root) + return storage +} + +// The blockcache helps prevent unnecessary IAVLTree updates and garbage generation. +type BlockCache struct { + db dbm.DB + backend *State + accounts map[string]accountInfo + storages map[Tuple256]storageInfo + names map[string]nameInfo +} + +func NewBlockCache(backend *State) *BlockCache { + return &BlockCache{ + db: backend.DB, + backend: backend, + accounts: make(map[string]accountInfo), + storages: make(map[Tuple256]storageInfo), + names: make(map[string]nameInfo), + } +} + +func (cache *BlockCache) State() *State { + return cache.backend +} + +//------------------------------------- +// BlockCache.account + +func (cache *BlockCache) GetAccount(addr []byte) *acm.Account { + acc, _, removed, _ := cache.accounts[string(addr)].unpack() + if removed { + return nil + } else if acc != nil { + return acc + } else { + acc = cache.backend.GetAccount(addr) + cache.accounts[string(addr)] = accountInfo{acc, nil, false, false} + return acc + } +} + +func (cache *BlockCache) UpdateAccount(acc *acm.Account) { + addr := acc.Address + _, storage, removed, _ := cache.accounts[string(addr)].unpack() + if removed { + PanicSanity("UpdateAccount on a removed account") + } + cache.accounts[string(addr)] = accountInfo{acc, storage, false, true} +} + +func (cache *BlockCache) RemoveAccount(addr []byte) { + _, _, removed, _ := cache.accounts[string(addr)].unpack() + if removed { + PanicSanity("RemoveAccount on a removed account") + } + cache.accounts[string(addr)] = accountInfo{nil, nil, true, false} +} + +// BlockCache.account +//------------------------------------- +// BlockCache.storage + +func (cache *BlockCache) GetStorage(addr Word256, key Word256) (value Word256) { + // Check cache + info, ok := cache.storages[Tuple256{addr, key}] + if ok { + return info.value + } + + // Get or load storage + acc, storage, removed, dirty := cache.accounts[string(addr.Postfix(20))].unpack() + if removed { + PanicSanity("GetStorage() on removed account") + } + if acc != nil && storage == nil { + storage = makeStorage(cache.db, acc.StorageRoot) + cache.accounts[string(addr.Postfix(20))] = accountInfo{acc, storage, false, dirty} + } else if acc == nil { + return Zero256 + } + + // Load and set cache + _, val_ := storage.Get(key.Bytes()) + value = Zero256 + if val_ != nil { + value = LeftPadWord256(val_.([]byte)) + } + cache.storages[Tuple256{addr, key}] = storageInfo{value, false} + return value +} + +// NOTE: Set value to zero to removed from the trie. +func (cache *BlockCache) SetStorage(addr Word256, key Word256, value Word256) { + _, _, removed, _ := cache.accounts[string(addr.Postfix(20))].unpack() + if removed { + PanicSanity("SetStorage() on a removed account") + } + cache.storages[Tuple256{addr, key}] = storageInfo{value, true} +} + +// BlockCache.storage +//------------------------------------- +// BlockCache.names + +func (cache *BlockCache) GetNameRegEntry(name string) *types.NameRegEntry { + entry, removed, _ := cache.names[name].unpack() + if removed { + return nil + } else if entry != nil { + return entry + } else { + entry = cache.backend.GetNameRegEntry(name) + cache.names[name] = nameInfo{entry, false, false} + return entry + } +} + +func (cache *BlockCache) UpdateNameRegEntry(entry *types.NameRegEntry) { + name := entry.Name + cache.names[name] = nameInfo{entry, false, true} +} + +func (cache *BlockCache) RemoveNameRegEntry(name string) { + _, removed, _ := cache.names[name].unpack() + if removed { + PanicSanity("RemoveNameRegEntry on a removed entry") + } + cache.names[name] = nameInfo{nil, true, false} +} + +// BlockCache.names +//------------------------------------- + +// CONTRACT the updates are in deterministic order. +func (cache *BlockCache) Sync() { + + // Determine order for storage updates + // The address comes first so it'll be grouped. + storageKeys := make([]Tuple256, 0, len(cache.storages)) + for keyTuple := range cache.storages { + storageKeys = append(storageKeys, keyTuple) + } + Tuple256Slice(storageKeys).Sort() + + // Update storage for all account/key. + // Later we'll iterate over all the users and save storage + update storage root. + var ( + curAddr Word256 + curAcc *acm.Account + curAccRemoved bool + curStorage merkle.Tree + ) + for _, storageKey := range storageKeys { + addr, key := Tuple256Split(storageKey) + if addr != curAddr || curAcc == nil { + acc, storage, removed, _ := cache.accounts[string(addr.Postfix(20))].unpack() + if !removed && storage == nil { + storage = makeStorage(cache.db, acc.StorageRoot) + } + curAddr = addr + curAcc = acc + curAccRemoved = removed + curStorage = storage + } + if curAccRemoved { + continue + } + value, dirty := cache.storages[storageKey].unpack() + if !dirty { + continue + } + if value.IsZero() { + curStorage.Remove(key.Bytes()) + } else { + curStorage.Set(key.Bytes(), value.Bytes()) + cache.accounts[string(addr.Postfix(20))] = accountInfo{curAcc, curStorage, false, true} + } + } + + // Determine order for accounts + addrStrs := []string{} + for addrStr := range cache.accounts { + addrStrs = append(addrStrs, addrStr) + } + sort.Strings(addrStrs) + + // Update or delete accounts. + for _, addrStr := range addrStrs { + acc, storage, removed, dirty := cache.accounts[addrStr].unpack() + if removed { + removed := cache.backend.RemoveAccount([]byte(addrStr)) + if !removed { + PanicCrisis(Fmt("Could not remove account to be removed: %X", acc.Address)) + } + } else { + if acc == nil { + continue + } + if storage != nil { + newStorageRoot := storage.Save() + if !bytes.Equal(newStorageRoot, acc.StorageRoot) { + acc.StorageRoot = newStorageRoot + dirty = true + } + } + if dirty { + cache.backend.UpdateAccount(acc) + } + } + } + + // Determine order for names + // note names may be of any length less than some limit + nameStrs := []string{} + for nameStr := range cache.names { + nameStrs = append(nameStrs, nameStr) + } + sort.Strings(nameStrs) + + // Update or delete names. + for _, nameStr := range nameStrs { + entry, removed, dirty := cache.names[nameStr].unpack() + if removed { + removed := cache.backend.RemoveNameRegEntry(nameStr) + if !removed { + PanicCrisis(Fmt("Could not remove namereg entry to be removed: %s", nameStr)) + } + } else { + if entry == nil { + continue + } + if dirty { + cache.backend.UpdateNameRegEntry(entry) + } + } + } + +} + +//----------------------------------------------------------------------------- + +type accountInfo struct { + account *acm.Account + storage merkle.Tree + removed bool + dirty bool +} + +func (accInfo accountInfo) unpack() (*acm.Account, merkle.Tree, bool, bool) { + return accInfo.account, accInfo.storage, accInfo.removed, accInfo.dirty +} + +type storageInfo struct { + value Word256 + dirty bool +} + +func (stjInfo storageInfo) unpack() (Word256, bool) { + return stjInfo.value, stjInfo.dirty +} + +type nameInfo struct { + name *types.NameRegEntry + removed bool + dirty bool +} + +func (nInfo nameInfo) unpack() (*types.NameRegEntry, bool, bool) { + return nInfo.name, nInfo.removed, nInfo.dirty +} diff --git a/state/common.go b/state/common.go new file mode 100644 index 0000000000000000000000000000000000000000..1f572a2108044082d9be6fbb0229af6a8418286f --- /dev/null +++ b/state/common.go @@ -0,0 +1,18 @@ +package state + +import ( + . "github.com/tendermint/go-common" + acm "github.com/eris-ltd/eris-db/account" + "github.com/eris-ltd/eris-db/evm" +) + +type AccountGetter interface { + GetAccount(addr []byte) *acm.Account +} + +type VMAccountState interface { + GetAccount(addr Word256) *vm.Account + UpdateAccount(acc *vm.Account) + RemoveAccount(acc *vm.Account) + CreateAccount(creator *vm.Account) *vm.Account +} diff --git a/state/execution.go b/state/execution.go new file mode 100644 index 0000000000000000000000000000000000000000..b4149fdecc2d6a1be862e3b43957baab830ad01c --- /dev/null +++ b/state/execution.go @@ -0,0 +1,1005 @@ +package state + +import ( + "bytes" + "errors" + "fmt" + + . "github.com/tendermint/go-common" + "github.com/tendermint/tendermint/events" + + acm "github.com/eris-ltd/eris-db/account" + "github.com/eris-ltd/eris-db/evm" + ptypes "github.com/eris-ltd/eris-db/permission/types" // for GlobalPermissionAddress ... + + "github.com/eris-ltd/eris-db/txs" +) + +// ExecBlock stuff is now taken care of by the consensus engine. +// But we leave here for now for reference when we have to do validator updates + +/* + +// NOTE: If an error occurs during block execution, state will be left +// at an invalid state. Copy the state before calling ExecBlock! +func ExecBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeader) error { + err := execBlock(s, block, blockPartsHeader) + if err != nil { + return err + } + // State.Hash should match block.StateHash + stateHash := s.Hash() + if !bytes.Equal(stateHash, block.StateHash) { + return errors.New(Fmt("Invalid state hash. Expected %X, got %X", + stateHash, block.StateHash)) + } + return nil +} + +// executes transactions of a block, does not check block.StateHash +// NOTE: If an error occurs during block execution, state will be left +// at an invalid state. Copy the state before calling execBlock! +func execBlock(s *State, block *types.Block, blockPartsHeader types.PartSetHeader) error { + // Basic block validation. + err := block.ValidateBasic(s.ChainID, s.LastBlockHeight, s.LastBlockHash, s.LastBlockParts, s.LastBlockTime) + if err != nil { + return err + } + + // Validate block LastValidation. + if block.Height == 1 { + if len(block.LastValidation.Precommits) != 0 { + return errors.New("Block at height 1 (first block) should have no LastValidation precommits") + } + } else { + if len(block.LastValidation.Precommits) != s.LastBondedValidators.Size() { + return errors.New(Fmt("Invalid block validation size. Expected %v, got %v", + s.LastBondedValidators.Size(), len(block.LastValidation.Precommits))) + } + err := s.LastBondedValidators.VerifyValidation( + s.ChainID, s.LastBlockHash, s.LastBlockParts, block.Height-1, block.LastValidation) + if err != nil { + return err + } + } + + // Update Validator.LastCommitHeight as necessary. + for i, precommit := range block.LastValidation.Precommits { + if precommit == nil { + continue + } + _, val := s.LastBondedValidators.GetByIndex(i) + if val == nil { + PanicCrisis(Fmt("Failed to fetch validator at index %v", i)) + } + if _, val_ := s.BondedValidators.GetByAddress(val.Address); val_ != nil { + val_.LastCommitHeight = block.Height - 1 + updated := s.BondedValidators.Update(val_) + if !updated { + PanicCrisis("Failed to update bonded validator LastCommitHeight") + } + } else if _, val_ := s.UnbondingValidators.GetByAddress(val.Address); val_ != nil { + val_.LastCommitHeight = block.Height - 1 + updated := s.UnbondingValidators.Update(val_) + if !updated { + PanicCrisis("Failed to update unbonding validator LastCommitHeight") + } + } else { + PanicCrisis("Could not find validator") + } + } + + // Remember LastBondedValidators + s.LastBondedValidators = s.BondedValidators.Copy() + + // Create BlockCache to cache changes to state. + blockCache := NewBlockCache(s) + + // Execute each tx + for _, tx := range block.Data.Txs { + err := ExecTx(blockCache, tx, true, s.evc) + if err != nil { + return InvalidTxError{tx, err} + } + } + + // Now sync the BlockCache to the backend. + blockCache.Sync() + + // If any unbonding periods are over, + // reward account with bonded coins. + toRelease := []*types.Validator{} + s.UnbondingValidators.Iterate(func(index int, val *types.Validator) bool { + if val.UnbondHeight+unbondingPeriodBlocks < block.Height { + toRelease = append(toRelease, val) + } + return false + }) + for _, val := range toRelease { + s.releaseValidator(val) + } + + // If any validators haven't signed in a while, + // unbond them, they have timed out. + toTimeout := []*types.Validator{} + s.BondedValidators.Iterate(func(index int, val *types.Validator) bool { + lastActivityHeight := MaxInt(val.BondHeight, val.LastCommitHeight) + if lastActivityHeight+validatorTimeoutBlocks < block.Height { + log.Notice("Validator timeout", "validator", val, "height", block.Height) + toTimeout = append(toTimeout, val) + } + return false + }) + for _, val := range toTimeout { + s.unbondValidator(val) + } + + // Increment validator AccumPowers + s.BondedValidators.IncrementAccum(1) + s.LastBlockHeight = block.Height + s.LastBlockHash = block.Hash() + s.LastBlockParts = blockPartsHeader + s.LastBlockTime = block.Time + return nil +} +*/ + +// The accounts from the TxInputs must either already have +// acm.PubKey.(type) != nil, (it must be known), +// or it must be specified in the TxInput. If redeclared, +// the TxInput is modified and input.PubKey set to nil. +func getInputs(state AccountGetter, ins []*types.TxInput) (map[string]*acm.Account, error) { + accounts := map[string]*acm.Account{} + for _, in := range ins { + // Account shouldn't be duplicated + if _, ok := accounts[string(in.Address)]; ok { + return nil, types.ErrTxDuplicateAddress + } + acc := state.GetAccount(in.Address) + if acc == nil { + return nil, types.ErrTxInvalidAddress + } + // PubKey should be present in either "account" or "in" + if err := checkInputPubKey(acc, in); err != nil { + return nil, err + } + accounts[string(in.Address)] = acc + } + return accounts, nil +} + +func getOrMakeOutputs(state AccountGetter, accounts map[string]*acm.Account, outs []*types.TxOutput) (map[string]*acm.Account, error) { + if accounts == nil { + accounts = make(map[string]*acm.Account) + } + + // we should err if an account is being created but the inputs don't have permission + var checkedCreatePerms bool + for _, out := range outs { + // Account shouldn't be duplicated + if _, ok := accounts[string(out.Address)]; ok { + return nil, types.ErrTxDuplicateAddress + } + acc := state.GetAccount(out.Address) + // output account may be nil (new) + if acc == nil { + if !checkedCreatePerms { + if !hasCreateAccountPermission(state, accounts) { + return nil, fmt.Errorf("At least one input does not have permission to create accounts") + } + checkedCreatePerms = true + } + acc = &acm.Account{ + Address: out.Address, + PubKey: nil, + Sequence: 0, + Balance: 0, + Permissions: ptypes.ZeroAccountPermissions, + } + } + accounts[string(out.Address)] = acc + } + return accounts, nil +} + +func checkInputPubKey(acc *acm.Account, in *types.TxInput) error { + if acc.PubKey == nil { + if in.PubKey == nil { + return types.ErrTxUnknownPubKey + } + if !bytes.Equal(in.PubKey.Address(), acc.Address) { + return types.ErrTxInvalidPubKey + } + acc.PubKey = in.PubKey + } else { + in.PubKey = nil + } + return nil +} + +func validateInputs(accounts map[string]*acm.Account, signBytes []byte, ins []*types.TxInput) (total int64, err error) { + for _, in := range ins { + acc := accounts[string(in.Address)] + if acc == nil { + PanicSanity("validateInputs() expects account in accounts") + } + err = validateInput(acc, signBytes, in) + if err != nil { + return + } + // Good. Add amount to total + total += in.Amount + } + return total, nil +} + +func validateInput(acc *acm.Account, signBytes []byte, in *types.TxInput) (err error) { + // Check TxInput basic + if err := in.ValidateBasic(); err != nil { + return err + } + // Check signatures + if !acc.PubKey.VerifyBytes(signBytes, in.Signature) { + return types.ErrTxInvalidSignature + } + // Check sequences + if acc.Sequence+1 != in.Sequence { + return types.ErrTxInvalidSequence{ + Got: in.Sequence, + Expected: acc.Sequence + 1, + } + } + // Check amount + if acc.Balance < in.Amount { + return types.ErrTxInsufficientFunds + } + return nil +} + +func validateOutputs(outs []*types.TxOutput) (total int64, err error) { + for _, out := range outs { + // Check TxOutput basic + if err := out.ValidateBasic(); err != nil { + return 0, err + } + // Good. Add amount to total + total += out.Amount + } + return total, nil +} + +func adjustByInputs(accounts map[string]*acm.Account, ins []*types.TxInput) { + for _, in := range ins { + acc := accounts[string(in.Address)] + if acc == nil { + PanicSanity("adjustByInputs() expects account in accounts") + } + if acc.Balance < in.Amount { + PanicSanity("adjustByInputs() expects sufficient funds") + } + acc.Balance -= in.Amount + acc.Sequence += 1 + } +} + +func adjustByOutputs(accounts map[string]*acm.Account, outs []*types.TxOutput) { + for _, out := range outs { + acc := accounts[string(out.Address)] + if acc == nil { + PanicSanity("adjustByOutputs() expects account in accounts") + } + acc.Balance += out.Amount + } +} + +// If the tx is invalid, an error will be returned. +// Unlike ExecBlock(), state will not be altered. +func ExecTx(blockCache *BlockCache, tx types.Tx, runCall bool, evc events.Fireable) (err error) { + + // TODO: do something with fees + fees := int64(0) + _s := blockCache.State() // hack to access validators and block height + + // Exec tx + switch tx := tx.(type) { + case *types.SendTx: + accounts, err := getInputs(blockCache, tx.Inputs) + if err != nil { + return err + } + + // ensure all inputs have send permissions + if !hasSendPermission(blockCache, accounts) { + return fmt.Errorf("At least one input lacks permission for SendTx") + } + + // add outputs to accounts map + // if any outputs don't exist, all inputs must have CreateAccount perm + accounts, err = getOrMakeOutputs(blockCache, accounts, tx.Outputs) + if err != nil { + return err + } + + signBytes := acm.SignBytes(_s.ChainID, tx) + inTotal, err := validateInputs(accounts, signBytes, tx.Inputs) + if err != nil { + return err + } + outTotal, err := validateOutputs(tx.Outputs) + if err != nil { + return err + } + if outTotal > inTotal { + return types.ErrTxInsufficientFunds + } + fee := inTotal - outTotal + fees += fee + + // Good! Adjust accounts + adjustByInputs(accounts, tx.Inputs) + adjustByOutputs(accounts, tx.Outputs) + for _, acc := range accounts { + blockCache.UpdateAccount(acc) + } + + // if the evc is nil, nothing will happen + if evc != nil { + for _, i := range tx.Inputs { + evc.FireEvent(types.EventStringAccInput(i.Address), types.EventDataTx{tx, nil, ""}) + } + + for _, o := range tx.Outputs { + evc.FireEvent(types.EventStringAccOutput(o.Address), types.EventDataTx{tx, nil, ""}) + } + } + return nil + + case *types.CallTx: + var inAcc, outAcc *acm.Account + + // Validate input + inAcc = blockCache.GetAccount(tx.Input.Address) + if inAcc == nil { + log.Info(Fmt("Can't find in account %X", tx.Input.Address)) + return types.ErrTxInvalidAddress + } + + createContract := len(tx.Address) == 0 + if createContract { + if !hasCreateContractPermission(blockCache, inAcc) { + return fmt.Errorf("Account %X does not have CreateContract permission", tx.Input.Address) + } + } else { + if !hasCallPermission(blockCache, inAcc) { + return fmt.Errorf("Account %X does not have Call permission", tx.Input.Address) + } + } + + // pubKey should be present in either "inAcc" or "tx.Input" + if err := checkInputPubKey(inAcc, tx.Input); err != nil { + log.Info(Fmt("Can't find pubkey for %X", tx.Input.Address)) + return err + } + signBytes := acm.SignBytes(_s.ChainID, tx) + err := validateInput(inAcc, signBytes, tx.Input) + if err != nil { + log.Info(Fmt("validateInput failed on %X: %v", tx.Input.Address, err)) + return err + } + if tx.Input.Amount < tx.Fee { + log.Info(Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address)) + return types.ErrTxInsufficientFunds + } + + if !createContract { + // Validate output + if len(tx.Address) != 20 { + log.Info(Fmt("Destination address is not 20 bytes %X", tx.Address)) + return types.ErrTxInvalidAddress + } + // check if its a native contract + if vm.RegisteredNativeContract(LeftPadWord256(tx.Address)) { + return fmt.Errorf("NativeContracts can not be called using CallTx. Use a contract or the appropriate tx type (eg. PermissionsTx, NameTx)") + } + + // Output account may be nil if we are still in mempool and contract was created in same block as this tx + // but that's fine, because the account will be created properly when the create tx runs in the block + // and then this won't return nil. otherwise, we take their fee + outAcc = blockCache.GetAccount(tx.Address) + } + + log.Info(Fmt("Out account: %v", outAcc)) + + // Good! + value := tx.Input.Amount - tx.Fee + inAcc.Sequence += 1 + inAcc.Balance -= tx.Fee + blockCache.UpdateAccount(inAcc) + + // The logic in runCall MUST NOT return. + if runCall { + + // VM call variables + var ( + gas int64 = tx.GasLimit + err error = nil + caller *vm.Account = toVMAccount(inAcc) + callee *vm.Account = nil // initialized below + code []byte = nil + ret []byte = nil + txCache = NewTxCache(blockCache) + params = vm.Params{ + BlockHeight: int64(_s.LastBlockHeight), + BlockHash: LeftPadWord256(_s.LastBlockHash), + BlockTime: _s.LastBlockTime.Unix(), + GasLimit: _s.GetGasLimit(), + } + ) + + if !createContract && (outAcc == nil || len(outAcc.Code) == 0) { + // if you call an account that doesn't exist + // or an account with no code then we take fees (sorry pal) + // NOTE: it's fine to create a contract and call it within one + // block (nonce will prevent re-ordering of those txs) + // but to create with one contract and call with another + // you have to wait a block to avoid a re-ordering attack + // that will take your fees + if outAcc == nil { + log.Info(Fmt("%X tries to call %X but it does not exist.", + inAcc.Address, tx.Address)) + } else { + log.Info(Fmt("%X tries to call %X but code is blank.", + inAcc.Address, tx.Address)) + } + err = types.ErrTxInvalidAddress + goto CALL_COMPLETE + } + + // get or create callee + if createContract { + // We already checked for permission + callee = txCache.CreateAccount(caller) + log.Info(Fmt("Created new contract %X", callee.Address)) + code = tx.Data + } else { + callee = toVMAccount(outAcc) + log.Info(Fmt("Calling contract %X with code %X", callee.Address, callee.Code)) + code = callee.Code + } + log.Info(Fmt("Code for this contract: %X", code)) + + // Run VM call and sync txCache to blockCache. + { // Capture scope for goto. + // Write caller/callee to txCache. + txCache.UpdateAccount(caller) + txCache.UpdateAccount(callee) + vmach := vm.NewVM(txCache, params, caller.Address, types.TxID(_s.ChainID, tx)) + vmach.SetFireable(evc) + // NOTE: Call() transfers the value from caller to callee iff call succeeds. + ret, err = vmach.Call(caller, callee, code, tx.Data, value, &gas) + if err != nil { + // Failure. Charge the gas fee. The 'value' was otherwise not transferred. + log.Info(Fmt("Error on execution: %v", err)) + goto CALL_COMPLETE + } + + log.Info("Successful execution") + if createContract { + callee.Code = ret + } + txCache.Sync() + } + + CALL_COMPLETE: // err may or may not be nil. + + // Create a receipt from the ret and whether errored. + log.Notice("VM call complete", "caller", caller, "callee", callee, "return", ret, "err", err) + + // Fire Events for sender and receiver + // a separate event will be fired from vm for each additional call + if evc != nil { + exception := "" + if err != nil { + exception = err.Error() + } + evc.FireEvent(types.EventStringAccInput(tx.Input.Address), types.EventDataTx{tx, ret, exception}) + evc.FireEvent(types.EventStringAccOutput(tx.Address), types.EventDataTx{tx, ret, exception}) + } + } else { + // The mempool does not call txs until + // the proposer determines the order of txs. + // So mempool will skip the actual .Call(), + // and only deduct from the caller's balance. + inAcc.Balance -= value + if createContract { + inAcc.Sequence += 1 + } + blockCache.UpdateAccount(inAcc) + } + + return nil + + case *types.NameTx: + var inAcc *acm.Account + + // Validate input + inAcc = blockCache.GetAccount(tx.Input.Address) + if inAcc == nil { + log.Info(Fmt("Can't find in account %X", tx.Input.Address)) + return types.ErrTxInvalidAddress + } + // check permission + if !hasNamePermission(blockCache, inAcc) { + return fmt.Errorf("Account %X does not have Name permission", tx.Input.Address) + } + // pubKey should be present in either "inAcc" or "tx.Input" + if err := checkInputPubKey(inAcc, tx.Input); err != nil { + log.Info(Fmt("Can't find pubkey for %X", tx.Input.Address)) + return err + } + signBytes := acm.SignBytes(_s.ChainID, tx) + err := validateInput(inAcc, signBytes, tx.Input) + if err != nil { + log.Info(Fmt("validateInput failed on %X: %v", tx.Input.Address, err)) + return err + } + // fee is in addition to the amount which is used to determine the TTL + if tx.Input.Amount < tx.Fee { + log.Info(Fmt("Sender did not send enough to cover the fee %X", tx.Input.Address)) + return types.ErrTxInsufficientFunds + } + + // validate the input strings + if err := tx.ValidateStrings(); err != nil { + return err + } + + value := tx.Input.Amount - tx.Fee + + // let's say cost of a name for one block is len(data) + 32 + costPerBlock := types.NameCostPerBlock(types.NameBaseCost(tx.Name, tx.Data)) + expiresIn := int(value / costPerBlock) + lastBlockHeight := _s.LastBlockHeight + + log.Info("New NameTx", "value", value, "costPerBlock", costPerBlock, "expiresIn", expiresIn, "lastBlock", lastBlockHeight) + + // check if the name exists + entry := blockCache.GetNameRegEntry(tx.Name) + + if entry != nil { + var expired bool + // if the entry already exists, and hasn't expired, we must be owner + if entry.Expires > lastBlockHeight { + // ensure we are owner + if bytes.Compare(entry.Owner, tx.Input.Address) != 0 { + log.Info(Fmt("Sender %X is trying to update a name (%s) for which he is not owner", tx.Input.Address, tx.Name)) + return types.ErrTxPermissionDenied + } + } else { + expired = true + } + + // no value and empty data means delete the entry + if value == 0 && len(tx.Data) == 0 { + // maybe we reward you for telling us we can delete this crap + // (owners if not expired, anyone if expired) + log.Info("Removing namereg entry", "name", entry.Name) + blockCache.RemoveNameRegEntry(entry.Name) + } else { + // update the entry by bumping the expiry + // and changing the data + if expired { + if expiresIn < types.MinNameRegistrationPeriod { + return errors.New(Fmt("Names must be registered for at least %d blocks", types.MinNameRegistrationPeriod)) + } + entry.Expires = lastBlockHeight + expiresIn + entry.Owner = tx.Input.Address + log.Info("An old namereg entry has expired and been reclaimed", "name", entry.Name, "expiresIn", expiresIn, "owner", entry.Owner) + } else { + // since the size of the data may have changed + // we use the total amount of "credit" + oldCredit := int64(entry.Expires-lastBlockHeight) * types.NameBaseCost(entry.Name, entry.Data) + credit := oldCredit + value + expiresIn = int(credit / costPerBlock) + if expiresIn < types.MinNameRegistrationPeriod { + return errors.New(Fmt("Names must be registered for at least %d blocks", types.MinNameRegistrationPeriod)) + } + entry.Expires = lastBlockHeight + expiresIn + log.Info("Updated namereg entry", "name", entry.Name, "expiresIn", expiresIn, "oldCredit", oldCredit, "value", value, "credit", credit) + } + entry.Data = tx.Data + blockCache.UpdateNameRegEntry(entry) + } + } else { + if expiresIn < types.MinNameRegistrationPeriod { + return errors.New(Fmt("Names must be registered for at least %d blocks", types.MinNameRegistrationPeriod)) + } + // entry does not exist, so create it + entry = &types.NameRegEntry{ + Name: tx.Name, + Owner: tx.Input.Address, + Data: tx.Data, + Expires: lastBlockHeight + expiresIn, + } + log.Info("Creating namereg entry", "name", entry.Name, "expiresIn", expiresIn) + blockCache.UpdateNameRegEntry(entry) + } + + // TODO: something with the value sent? + + // Good! + inAcc.Sequence += 1 + inAcc.Balance -= value + blockCache.UpdateAccount(inAcc) + + // TODO: maybe we want to take funds on error and allow txs in that don't do anythingi? + + if evc != nil { + evc.FireEvent(types.EventStringAccInput(tx.Input.Address), types.EventDataTx{tx, nil, ""}) + evc.FireEvent(types.EventStringNameReg(tx.Name), types.EventDataTx{tx, nil, ""}) + } + + return nil + + // Consensus related Txs inactivated for now + // TODO! + /* + case *types.BondTx: + valInfo := blockCache.State().GetValidatorInfo(tx.PubKey.Address()) + if valInfo != nil { + // TODO: In the future, check that the validator wasn't destroyed, + // add funds, merge UnbondTo outputs, and unbond validator. + return errors.New("Adding coins to existing validators not yet supported") + } + + accounts, err := getInputs(blockCache, tx.Inputs) + if err != nil { + return err + } + + // add outputs to accounts map + // if any outputs don't exist, all inputs must have CreateAccount perm + // though outputs aren't created until unbonding/release time + canCreate := hasCreateAccountPermission(blockCache, accounts) + for _, out := range tx.UnbondTo { + acc := blockCache.GetAccount(out.Address) + if acc == nil && !canCreate { + return fmt.Errorf("At least one input does not have permission to create accounts") + } + } + + bondAcc := blockCache.GetAccount(tx.PubKey.Address()) + if !hasBondPermission(blockCache, bondAcc) { + return fmt.Errorf("The bonder does not have permission to bond") + } + + if !hasBondOrSendPermission(blockCache, accounts) { + return fmt.Errorf("At least one input lacks permission to bond") + } + + signBytes := acm.SignBytes(_s.ChainID, tx) + inTotal, err := validateInputs(accounts, signBytes, tx.Inputs) + if err != nil { + return err + } + if !tx.PubKey.VerifyBytes(signBytes, tx.Signature) { + return types.ErrTxInvalidSignature + } + outTotal, err := validateOutputs(tx.UnbondTo) + if err != nil { + return err + } + if outTotal > inTotal { + return types.ErrTxInsufficientFunds + } + fee := inTotal - outTotal + fees += fee + + // Good! Adjust accounts + adjustByInputs(accounts, tx.Inputs) + for _, acc := range accounts { + blockCache.UpdateAccount(acc) + } + // Add ValidatorInfo + _s.SetValidatorInfo(&types.ValidatorInfo{ + Address: tx.PubKey.Address(), + PubKey: tx.PubKey, + UnbondTo: tx.UnbondTo, + FirstBondHeight: _s.LastBlockHeight + 1, + FirstBondAmount: outTotal, + }) + // Add Validator + added := _s.BondedValidators.Add(&types.Validator{ + Address: tx.PubKey.Address(), + PubKey: tx.PubKey, + BondHeight: _s.LastBlockHeight + 1, + VotingPower: outTotal, + Accum: 0, + }) + if !added { + PanicCrisis("Failed to add validator") + } + if evc != nil { + // TODO: fire for all inputs + evc.FireEvent(types.EventStringBond(), types.EventDataTx{tx, nil, ""}) + } + return nil + + case *types.UnbondTx: + // The validator must be active + _, val := _s.BondedValidators.GetByAddress(tx.Address) + if val == nil { + return types.ErrTxInvalidAddress + } + + // Verify the signature + signBytes := acm.SignBytes(_s.ChainID, tx) + if !val.PubKey.VerifyBytes(signBytes, tx.Signature) { + return types.ErrTxInvalidSignature + } + + // tx.Height must be greater than val.LastCommitHeight + if tx.Height <= val.LastCommitHeight { + return errors.New("Invalid unbond height") + } + + // Good! + _s.unbondValidator(val) + if evc != nil { + evc.FireEvent(types.EventStringUnbond(), types.EventDataTx{tx, nil, ""}) + } + return nil + + case *types.RebondTx: + // The validator must be inactive + _, val := _s.UnbondingValidators.GetByAddress(tx.Address) + if val == nil { + return types.ErrTxInvalidAddress + } + + // Verify the signature + signBytes := acm.SignBytes(_s.ChainID, tx) + if !val.PubKey.VerifyBytes(signBytes, tx.Signature) { + return types.ErrTxInvalidSignature + } + + // tx.Height must be in a suitable range + minRebondHeight := _s.LastBlockHeight - (validatorTimeoutBlocks / 2) + maxRebondHeight := _s.LastBlockHeight + 2 + if !((minRebondHeight <= tx.Height) && (tx.Height <= maxRebondHeight)) { + return errors.New(Fmt("Rebond height not in range. Expected %v <= %v <= %v", + minRebondHeight, tx.Height, maxRebondHeight)) + } + + // Good! + _s.rebondValidator(val) + if evc != nil { + evc.FireEvent(types.EventStringRebond(), types.EventDataTx{tx, nil, ""}) + } + return nil + + case *types.DupeoutTx: + // Verify the signatures + _, accused := _s.BondedValidators.GetByAddress(tx.Address) + if accused == nil { + _, accused = _s.UnbondingValidators.GetByAddress(tx.Address) + if accused == nil { + return types.ErrTxInvalidAddress + } + } + voteASignBytes := acm.SignBytes(_s.ChainID, &tx.VoteA) + voteBSignBytes := acm.SignBytes(_s.ChainID, &tx.VoteB) + if !accused.PubKey.VerifyBytes(voteASignBytes, tx.VoteA.Signature) || + !accused.PubKey.VerifyBytes(voteBSignBytes, tx.VoteB.Signature) { + return types.ErrTxInvalidSignature + } + + // Verify equivocation + // TODO: in the future, just require one vote from a previous height that + // doesn't exist on this chain. + if tx.VoteA.Height != tx.VoteB.Height { + return errors.New("DupeoutTx heights don't match") + } + if tx.VoteA.Round != tx.VoteB.Round { + return errors.New("DupeoutTx rounds don't match") + } + if tx.VoteA.Type != tx.VoteB.Type { + return errors.New("DupeoutTx types don't match") + } + if bytes.Equal(tx.VoteA.BlockHash, tx.VoteB.BlockHash) { + return errors.New("DupeoutTx blockhashes shouldn't match") + } + + // Good! (Bad validator!) + _s.destroyValidator(accused) + if evc != nil { + evc.FireEvent(types.EventStringDupeout(), types.EventDataTx{tx, nil, ""}) + } + return nil + */ + + case *types.PermissionsTx: + var inAcc *acm.Account + + // Validate input + inAcc = blockCache.GetAccount(tx.Input.Address) + if inAcc == nil { + log.Debug(Fmt("Can't find in account %X", tx.Input.Address)) + return types.ErrTxInvalidAddress + } + + permFlag := tx.PermArgs.PermFlag() + // check permission + if !HasPermission(blockCache, inAcc, permFlag) { + return fmt.Errorf("Account %X does not have moderator permission %s (%b)", tx.Input.Address, ptypes.PermFlagToString(permFlag), permFlag) + } + + // pubKey should be present in either "inAcc" or "tx.Input" + if err := checkInputPubKey(inAcc, tx.Input); err != nil { + log.Debug(Fmt("Can't find pubkey for %X", tx.Input.Address)) + return err + } + signBytes := acm.SignBytes(_s.ChainID, tx) + err := validateInput(inAcc, signBytes, tx.Input) + if err != nil { + log.Debug(Fmt("validateInput failed on %X: %v", tx.Input.Address, err)) + return err + } + + value := tx.Input.Amount + + log.Debug("New PermissionsTx", "function", ptypes.PermFlagToString(permFlag), "args", tx.PermArgs) + + var permAcc *acm.Account + switch args := tx.PermArgs.(type) { + case *ptypes.HasBaseArgs: + // this one doesn't make sense from txs + return fmt.Errorf("HasBase is for contracts, not humans. Just look at the blockchain") + case *ptypes.SetBaseArgs: + if permAcc = blockCache.GetAccount(args.Address); permAcc == nil { + return fmt.Errorf("Trying to update permissions for unknown account %X", args.Address) + } + err = permAcc.Permissions.Base.Set(args.Permission, args.Value) + case *ptypes.UnsetBaseArgs: + if permAcc = blockCache.GetAccount(args.Address); permAcc == nil { + return fmt.Errorf("Trying to update permissions for unknown account %X", args.Address) + } + err = permAcc.Permissions.Base.Unset(args.Permission) + case *ptypes.SetGlobalArgs: + if permAcc = blockCache.GetAccount(ptypes.GlobalPermissionsAddress); permAcc == nil { + PanicSanity("can't find global permissions account") + } + err = permAcc.Permissions.Base.Set(args.Permission, args.Value) + case *ptypes.HasRoleArgs: + return fmt.Errorf("HasRole is for contracts, not humans. Just look at the blockchain") + case *ptypes.AddRoleArgs: + if permAcc = blockCache.GetAccount(args.Address); permAcc == nil { + return fmt.Errorf("Trying to update roles for unknown account %X", args.Address) + } + if !permAcc.Permissions.AddRole(args.Role) { + return fmt.Errorf("Role (%s) already exists for account %X", args.Role, args.Address) + } + case *ptypes.RmRoleArgs: + if permAcc = blockCache.GetAccount(args.Address); permAcc == nil { + return fmt.Errorf("Trying to update roles for unknown account %X", args.Address) + } + if !permAcc.Permissions.RmRole(args.Role) { + return fmt.Errorf("Role (%s) does not exist for account %X", args.Role, args.Address) + } + default: + PanicSanity(Fmt("invalid permission function: %s", ptypes.PermFlagToString(permFlag))) + } + + // TODO: maybe we want to take funds on error and allow txs in that don't do anythingi? + if err != nil { + return err + } + + // Good! + inAcc.Sequence += 1 + inAcc.Balance -= value + blockCache.UpdateAccount(inAcc) + if permAcc != nil { + blockCache.UpdateAccount(permAcc) + } + + if evc != nil { + evc.FireEvent(types.EventStringAccInput(tx.Input.Address), types.EventDataTx{tx, nil, ""}) + evc.FireEvent(types.EventStringPermissions(ptypes.PermFlagToString(permFlag)), types.EventDataTx{tx, nil, ""}) + } + + return nil + + default: + // binary decoding should not let this happen + PanicSanity("Unknown Tx type") + return nil + } +} + +//--------------------------------------------------------------- + +// Get permission on an account or fall back to global value +func HasPermission(state AccountGetter, acc *acm.Account, perm ptypes.PermFlag) bool { + if perm > ptypes.AllPermFlags { + PanicSanity("Checking an unknown permission in state should never happen") + } + + if acc == nil { + // TODO + // this needs to fall back to global or do some other specific things + // eg. a bondAcc may be nil and so can only bond if global bonding is true + } + permString := ptypes.PermFlagToString(perm) + + v, err := acc.Permissions.Base.Get(perm) + if _, ok := err.(ptypes.ErrValueNotSet); ok { + if state == nil { + PanicSanity("All known global permissions should be set!") + } + log.Info("Permission for account is not set. Querying GlobalPermissionsAddress", "perm", permString) + return HasPermission(nil, state.GetAccount(ptypes.GlobalPermissionsAddress), perm) + } else if v { + log.Info("Account has permission", "address", Fmt("%X", acc.Address), "perm", permString) + } else { + log.Info("Account does not have permission", "address", Fmt("%X", acc.Address), "perm", permString) + } + return v +} + +// TODO: for debug log the failed accounts +func hasSendPermission(state AccountGetter, accs map[string]*acm.Account) bool { + for _, acc := range accs { + if !HasPermission(state, acc, ptypes.Send) { + return false + } + } + return true +} + +func hasNamePermission(state AccountGetter, acc *acm.Account) bool { + return HasPermission(state, acc, ptypes.Name) +} + +func hasCallPermission(state AccountGetter, acc *acm.Account) bool { + return HasPermission(state, acc, ptypes.Call) +} + +func hasCreateContractPermission(state AccountGetter, acc *acm.Account) bool { + return HasPermission(state, acc, ptypes.CreateContract) +} + +func hasCreateAccountPermission(state AccountGetter, accs map[string]*acm.Account) bool { + for _, acc := range accs { + if !HasPermission(state, acc, ptypes.CreateAccount) { + return false + } + } + return true +} + +func hasBondPermission(state AccountGetter, acc *acm.Account) bool { + return HasPermission(state, acc, ptypes.Bond) +} + +func hasBondOrSendPermission(state AccountGetter, accs map[string]*acm.Account) bool { + for _, acc := range accs { + if !HasPermission(state, acc, ptypes.Bond) { + if !HasPermission(state, acc, ptypes.Send) { + return false + } + } + } + return true +} + +//----------------------------------------------------------------------------- + +type InvalidTxError struct { + Tx types.Tx + Reason error +} + +func (txErr InvalidTxError) Error() string { + return Fmt("Invalid tx: [%v] reason: [%v]", txErr.Tx, txErr.Reason) +} diff --git a/state/genesis_test.go b/state/genesis_test.go new file mode 100644 index 0000000000000000000000000000000000000000..e47f98f8cd8197bfd7dd90108773d521c9c034bd --- /dev/null +++ b/state/genesis_test.go @@ -0,0 +1,87 @@ +package state + +import ( + "bytes" + "encoding/hex" + "fmt" + "testing" + + tdb "github.com/tendermint/go-db" + ptypes "github.com/eris-ltd/eris-db/permission/types" + . "github.com/eris-ltd/eris-db/state/types" +) + +var chain_id = "lone_ranger" +var addr1, _ = hex.DecodeString("964B1493BBE3312278B7DEB94C39149F7899A345") +var send1, name1, call1 = 1, 1, 0 +var perms, setbit = 66, 70 +var accName = "me" +var roles1 = []string{"master", "universal-ruler"} +var amt1 int64 = 1000000 +var g1 = fmt.Sprintf(` +{ + "chain_id":"%s", + "accounts": [ + { + "address": "%X", + "amount": %d, + "name": "%s", + "permissions": { + "base": { + "perms": %d, + "set": %d + }, + "roles": [ + "%s", + "%s" + ] + } + } + ], + "validators": [ + { + "amount": 100000000, + "pub_key": [1,"F6C79CF0CB9D66B677988BCB9B8EADD9A091CD465A60542A8AB85476256DBA92"], + "unbond_to": [ + { + "address": "964B1493BBE3312278B7DEB94C39149F7899A345", + "amount": 10000000 + } + ] + } + ] +} +`, chain_id, addr1, amt1, accName, perms, setbit, roles1[0], roles1[1]) + +func TestGenesisReadable(t *testing.T) { + genDoc := GenesisDocFromJSON([]byte(g1)) + if genDoc.ChainID != chain_id { + t.Fatalf("Incorrect chain id. Got %d, expected %d\n", genDoc.ChainID, chain_id) + } + acc := genDoc.Accounts[0] + if bytes.Compare(acc.Address, addr1) != 0 { + t.Fatalf("Incorrect address for account. Got %X, expected %X\n", acc.Address, addr1) + } + if acc.Amount != amt1 { + t.Fatalf("Incorrect amount for account. Got %d, expected %d\n", acc.Amount, amt1) + } + if acc.Name != accName { + t.Fatalf("Incorrect name for account. Got %s, expected %s\n", acc.Name, accName) + } + + perm, _ := acc.Permissions.Base.Get(ptypes.Send) + if perm != (send1 > 0) { + t.Fatalf("Incorrect permission for send. Got %v, expected %v\n", perm, send1 > 0) + } +} + +func TestGenesisMakeState(t *testing.T) { + genDoc := GenesisDocFromJSON([]byte(g1)) + db := tdb.NewMemDB() + st := MakeGenesisState(db, genDoc) + acc := st.GetAccount(addr1) + v, _ := acc.Permissions.Base.Get(ptypes.Send) + if v != (send1 > 0) { + t.Fatalf("Incorrect permission for send. Got %v, expected %v\n", v, send1 > 0) + } +} diff --git a/state/log.go b/state/log.go new file mode 100644 index 0000000000000000000000000000000000000000..5b102b5703e0474c1ee2db377f3b95c7a8705c3c --- /dev/null +++ b/state/log.go @@ -0,0 +1,7 @@ +package state + +import ( + "github.com/tendermint/go-logger" +) + +var log = logger.New("module", "state") diff --git a/state/permissions_test.go b/state/permissions_test.go new file mode 100644 index 0000000000000000000000000000000000000000..15443688e4c874fd86f7bf12aa954bf5f7b3ea97 --- /dev/null +++ b/state/permissions_test.go @@ -0,0 +1,1265 @@ +package state + +import ( + "bytes" + "fmt" + "strconv" + "testing" + "time" + + . "github.com/tendermint/go-common" + dbm "github.com/tendermint/go-db" + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/types" + acm "github.com/eris-ltd/eris-db/account" + ptypes "github.com/eris-ltd/eris-db/permission/types" + . "github.com/eris-ltd/eris-db/state/types" +) + +/* +Permission Tests: + +- SendTx: +x - 1 input, no perm, call perm, create perm +x - 1 input, perm +x - 2 inputs, one with perm one without + +- CallTx, CALL +x - 1 input, no perm, send perm, create perm +x - 1 input, perm +x - contract runs call but doesn't have call perm +x - contract runs call and has call perm +x - contract runs call (with perm), runs contract that runs call (without perm) +x - contract runs call (with perm), runs contract that runs call (with perm) + +- CallTx for Create, CREATE +x - 1 input, no perm, send perm, call perm +x - 1 input, perm +x - contract runs create but doesn't have create perm +x - contract runs create but has perm +x - contract runs call with empty address (has call and create perm) + +- NameTx + - no perm, send perm, call perm + - with perm + +- BondTx +x - 1 input, no perm +x - 1 input, perm +x - 1 bonder with perm, input without send or bond +x - 1 bonder with perm, input with send +x - 1 bonder with perm, input with bond +x - 2 inputs, one with perm one without + +- SendTx for new account +x - 1 input, 1 unknown ouput, input with send, not create (fail) +x - 1 input, 1 unknown ouput, input with send and create (pass) +x - 2 inputs, 1 unknown ouput, both inputs with send, one with create, one without (fail) +x - 2 inputs, 1 known output, 1 unknown ouput, one input with create, one without (fail) +x - 2 inputs, 1 unknown ouput, both inputs with send, both inputs with create (pass ) +x - 2 inputs, 1 known output, 1 unknown ouput, both inputs with create, (pass) + + +- CALL for new account +x - unknown output, without create (fail) +x - unknown output, with create (pass) + + +- SNative (CallTx, CALL): + - for each of CallTx, Call +x - call each snative without permission, fails +x - call each snative with permission, pass + - list: +x - base: has,set,unset +x - globals: set +x - roles: has, add, rm + + +*/ + +// keys +var user = makeUsers(10) +var chainID = "testchain" + +func makeUsers(n int) []*acm.PrivAccount { + accounts := []*acm.PrivAccount{} + for i := 0; i < n; i++ { + secret := ("mysecret" + strconv.Itoa(i)) + user := acm.GenPrivAccountFromSecret(secret) + accounts = append(accounts, user) + } + return accounts +} + +var ( + PermsAllFalse = ptypes.ZeroAccountPermissions +) + +func newBaseGenDoc(globalPerm, accountPerm ptypes.AccountPermissions) GenesisDoc { + genAccounts := []GenesisAccount{} + for _, u := range user[:5] { + accountPermCopy := accountPerm // Create new instance for custom overridability. + genAccounts = append(genAccounts, GenesisAccount{ + Address: u.Address, + Amount: 1000000, + Permissions: &accountPermCopy, + }) + } + + return GenesisDoc{ + GenesisTime: time.Now(), + ChainID: chainID, + Params: &GenesisParams{ + GlobalPermissions: &globalPerm, + }, + Accounts: genAccounts, + Validators: []GenesisValidator{ + GenesisValidator{ + PubKey: user[0].PubKey.(acm.PubKeyEd25519), + Amount: 10, + UnbondTo: []BasicAccount{ + BasicAccount{ + Address: user[0].Address, + }, + }, + }, + }, + } +} + +func TestSendFails(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[1].Permissions.Base.Set(ptypes.Send, true) + genDoc.Accounts[2].Permissions.Base.Set(ptypes.Call, true) + genDoc.Accounts[3].Permissions.Base.Set(ptypes.CreateContract, true) + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //------------------- + // send txs + + // simple send tx should fail + tx := types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[1].Address, 5) + tx.SignInput(chainID, 0, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple send tx with call perm should fail + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[2].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[4].Address, 5) + tx.SignInput(chainID, 0, user[2]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple send tx with create perm should fail + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[3].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[4].Address, 5) + tx.SignInput(chainID, 0, user[3]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple send tx to unknown account without create_account perm should fail + acc := blockCache.GetAccount(user[3].Address) + acc.Permissions.Base.Set(ptypes.Send, true) + blockCache.UpdateAccount(acc) + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[3].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[6].Address, 5) + tx.SignInput(chainID, 0, user[3]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } +} + +func TestName(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[0].Permissions.Base.Set(ptypes.Send, true) + genDoc.Accounts[1].Permissions.Base.Set(ptypes.Name, true) + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //------------------- + // name txs + + // simple name tx without perm should fail + tx, err := types.NewNameTx(st, user[0].PubKey, "somename", "somedata", 10000, 100) + if err != nil { + t.Fatal(err) + } + tx.Sign(chainID, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple name tx with perm should pass + tx, err = types.NewNameTx(st, user[1].PubKey, "somename", "somedata", 10000, 100) + if err != nil { + t.Fatal(err) + } + tx.Sign(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal(err) + } +} + +func TestCallFails(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[1].Permissions.Base.Set(ptypes.Send, true) + genDoc.Accounts[2].Permissions.Base.Set(ptypes.Call, true) + genDoc.Accounts[3].Permissions.Base.Set(ptypes.CreateContract, true) + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //------------------- + // call txs + + // simple call tx should fail + tx, _ := types.NewCallTx(blockCache, user[0].PubKey, user[4].Address, nil, 100, 100, 100) + tx.Sign(chainID, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple call tx with send permission should fail + tx, _ = types.NewCallTx(blockCache, user[1].PubKey, user[4].Address, nil, 100, 100, 100) + tx.Sign(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple call tx with create permission should fail + tx, _ = types.NewCallTx(blockCache, user[3].PubKey, user[4].Address, nil, 100, 100, 100) + tx.Sign(chainID, user[3]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + //------------------- + // create txs + + // simple call create tx should fail + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, nil, nil, 100, 100, 100) + tx.Sign(chainID, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple call create tx with send perm should fail + tx, _ = types.NewCallTx(blockCache, user[1].PubKey, nil, nil, 100, 100, 100) + tx.Sign(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // simple call create tx with call perm should fail + tx, _ = types.NewCallTx(blockCache, user[2].PubKey, nil, nil, 100, 100, 100) + tx.Sign(chainID, user[2]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } +} + +func TestSendPermission(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[0].Permissions.Base.Set(ptypes.Send, true) // give the 0 account permission + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + // A single input, having the permission, should succeed + tx := types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[1].Address, 5) + tx.SignInput(chainID, 0, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Transaction failed", err) + } + + // Two inputs, one with permission, one without, should fail + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + if err := tx.AddInput(blockCache, user[1].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[2].Address, 10) + tx.SignInput(chainID, 0, user[0]) + tx.SignInput(chainID, 1, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } +} + +func TestCallPermission(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[0].Permissions.Base.Set(ptypes.Call, true) // give the 0 account permission + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //------------------------------ + // call to simple contract + fmt.Println("\n##### SIMPLE CONTRACT") + + // create simple contract + simpleContractAddr := NewContractAddress(user[0].Address, 100) + simpleAcc := &acm.Account{ + Address: simpleContractAddr, + Balance: 0, + Code: []byte{0x60}, + Sequence: 0, + StorageRoot: Zero256.Bytes(), + Permissions: ptypes.ZeroAccountPermissions, + } + st.UpdateAccount(simpleAcc) + + // A single input, having the permission, should succeed + tx, _ := types.NewCallTx(blockCache, user[0].PubKey, simpleContractAddr, nil, 100, 100, 100) + tx.Sign(chainID, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Transaction failed", err) + } + + //---------------------------------------------------------- + // call to contract that calls simple contract - without perm + fmt.Println("\n##### CALL TO SIMPLE CONTRACT (FAIL)") + + // create contract that calls the simple contract + contractCode := callContractCode(simpleContractAddr) + caller1ContractAddr := NewContractAddress(user[0].Address, 101) + caller1Acc := &acm.Account{ + Address: caller1ContractAddr, + Balance: 10000, + Code: contractCode, + Sequence: 0, + StorageRoot: Zero256.Bytes(), + Permissions: ptypes.ZeroAccountPermissions, + } + blockCache.UpdateAccount(caller1Acc) + + // A single input, having the permission, but the contract doesn't have permission + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) + tx.Sign(chainID, user[0]) + + // we need to subscribe to the Call event to detect the exception + _, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // + if exception == "" { + t.Fatal("Expected exception") + } + + //---------------------------------------------------------- + // call to contract that calls simple contract - with perm + fmt.Println("\n##### CALL TO SIMPLE CONTRACT (PASS)") + + // A single input, having the permission, and the contract has permission + caller1Acc.Permissions.Base.Set(ptypes.Call, true) + blockCache.UpdateAccount(caller1Acc) + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) + tx.Sign(chainID, user[0]) + + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // + if exception != "" { + t.Fatal("Unexpected exception:", exception) + } + + //---------------------------------------------------------- + // call to contract that calls contract that calls simple contract - without perm + // caller1Contract calls simpleContract. caller2Contract calls caller1Contract. + // caller1Contract does not have call perms, but caller2Contract does. + fmt.Println("\n##### CALL TO CONTRACT CALLING SIMPLE CONTRACT (FAIL)") + + contractCode2 := callContractCode(caller1ContractAddr) + caller2ContractAddr := NewContractAddress(user[0].Address, 102) + caller2Acc := &acm.Account{ + Address: caller2ContractAddr, + Balance: 1000, + Code: contractCode2, + Sequence: 0, + StorageRoot: Zero256.Bytes(), + Permissions: ptypes.ZeroAccountPermissions, + } + caller1Acc.Permissions.Base.Set(ptypes.Call, false) + caller2Acc.Permissions.Base.Set(ptypes.Call, true) + blockCache.UpdateAccount(caller1Acc) + blockCache.UpdateAccount(caller2Acc) + + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller2ContractAddr, nil, 100, 10000, 100) + tx.Sign(chainID, user[0]) + + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // + if exception == "" { + t.Fatal("Expected exception") + } + + //---------------------------------------------------------- + // call to contract that calls contract that calls simple contract - without perm + // caller1Contract calls simpleContract. caller2Contract calls caller1Contract. + // both caller1 and caller2 have permission + fmt.Println("\n##### CALL TO CONTRACT CALLING SIMPLE CONTRACT (PASS)") + + caller1Acc.Permissions.Base.Set(ptypes.Call, true) + blockCache.UpdateAccount(caller1Acc) + + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, caller2ContractAddr, nil, 100, 10000, 100) + tx.Sign(chainID, user[0]) + + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(caller1ContractAddr)) // + if exception != "" { + t.Fatal("Unexpected exception", exception) + } +} + +func TestCreatePermission(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[0].Permissions.Base.Set(ptypes.CreateContract, true) // give the 0 account permission + genDoc.Accounts[0].Permissions.Base.Set(ptypes.Call, true) // give the 0 account permission + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //------------------------------ + // create a simple contract + fmt.Println("\n##### CREATE SIMPLE CONTRACT") + + contractCode := []byte{0x60} + createCode := wrapContractForCreate(contractCode) + + // A single input, having the permission, should succeed + tx, _ := types.NewCallTx(blockCache, user[0].PubKey, nil, createCode, 100, 100, 100) + tx.Sign(chainID, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Transaction failed", err) + } + // ensure the contract is there + contractAddr := NewContractAddress(tx.Input.Address, tx.Input.Sequence) + contractAcc := blockCache.GetAccount(contractAddr) + if contractAcc == nil { + t.Fatalf("failed to create contract %X", contractAddr) + } + if bytes.Compare(contractAcc.Code, contractCode) != 0 { + t.Fatalf("contract does not have correct code. Got %X, expected %X", contractAcc.Code, contractCode) + } + + //------------------------------ + // create contract that uses the CREATE op + fmt.Println("\n##### CREATE FACTORY") + + contractCode = []byte{0x60} + createCode = wrapContractForCreate(contractCode) + factoryCode := createContractCode() + createFactoryCode := wrapContractForCreate(factoryCode) + + // A single input, having the permission, should succeed + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, nil, createFactoryCode, 100, 100, 100) + tx.Sign(chainID, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Transaction failed", err) + } + // ensure the contract is there + contractAddr = NewContractAddress(tx.Input.Address, tx.Input.Sequence) + contractAcc = blockCache.GetAccount(contractAddr) + if contractAcc == nil { + t.Fatalf("failed to create contract %X", contractAddr) + } + if bytes.Compare(contractAcc.Code, factoryCode) != 0 { + t.Fatalf("contract does not have correct code. Got %X, expected %X", contractAcc.Code, factoryCode) + } + + //------------------------------ + // call the contract (should FAIL) + fmt.Println("\n###### CALL THE FACTORY (FAIL)") + + // A single input, having the permission, should succeed + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, contractAddr, createCode, 100, 100, 100) + tx.Sign(chainID, user[0]) + // we need to subscribe to the Call event to detect the exception + _, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(contractAddr)) // + if exception == "" { + t.Fatal("expected exception") + } + + //------------------------------ + // call the contract (should PASS) + fmt.Println("\n###### CALL THE FACTORY (PASS)") + + contractAcc.Permissions.Base.Set(ptypes.CreateContract, true) + blockCache.UpdateAccount(contractAcc) + + // A single input, having the permission, should succeed + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, contractAddr, createCode, 100, 100, 100) + tx.Sign(chainID, user[0]) + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(contractAddr)) // + if exception != "" { + t.Fatal("unexpected exception", exception) + } + + //-------------------------------- + fmt.Println("\n##### CALL to empty address") + zeroAddr := LeftPadBytes([]byte{}, 20) + code := callContractCode(zeroAddr) + + contractAddr = NewContractAddress(user[0].Address, 110) + contractAcc = &acm.Account{ + Address: contractAddr, + Balance: 1000, + Code: code, + Sequence: 0, + StorageRoot: Zero256.Bytes(), + Permissions: ptypes.ZeroAccountPermissions, + } + contractAcc.Permissions.Base.Set(ptypes.Call, true) + contractAcc.Permissions.Base.Set(ptypes.CreateContract, true) + blockCache.UpdateAccount(contractAcc) + + // this should call the 0 address but not create ... + tx, _ = types.NewCallTx(blockCache, user[0].PubKey, contractAddr, createCode, 100, 10000, 100) + tx.Sign(chainID, user[0]) + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(zeroAddr)) // + if exception != "" { + t.Fatal("unexpected exception", exception) + } + zeroAcc := blockCache.GetAccount(zeroAddr) + if len(zeroAcc.Code) != 0 { + t.Fatal("the zero account was given code from a CALL!") + } +} + +func TestBondPermission(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + var bondAcc *acm.Account + + //------------------------------ + // one bonder without permission should fail + tx, _ := types.NewBondTx(user[1].PubKey) + if err := tx.AddInput(blockCache, user[1].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[1].Address, 5) + tx.SignInput(chainID, 0, user[1]) + tx.SignBond(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + //------------------------------ + // one bonder with permission should pass + bondAcc = blockCache.GetAccount(user[1].Address) + bondAcc.Permissions.Base.Set(ptypes.Bond, true) + blockCache.UpdateAccount(bondAcc) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Unexpected error", err) + } + + // reset state (we can only bond with an account once ..) + genDoc = newBaseGenDoc(PermsAllFalse, PermsAllFalse) + st = MakeGenesisState(stateDB, &genDoc) + blockCache = NewBlockCache(st) + bondAcc = blockCache.GetAccount(user[1].Address) + bondAcc.Permissions.Base.Set(ptypes.Bond, true) + blockCache.UpdateAccount(bondAcc) + //------------------------------ + // one bonder with permission and an input without send should fail + tx, _ = types.NewBondTx(user[1].PubKey) + if err := tx.AddInput(blockCache, user[2].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[1].Address, 5) + tx.SignInput(chainID, 0, user[2]) + tx.SignBond(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // reset state (we can only bond with an account once ..) + genDoc = newBaseGenDoc(PermsAllFalse, PermsAllFalse) + st = MakeGenesisState(stateDB, &genDoc) + blockCache = NewBlockCache(st) + bondAcc = blockCache.GetAccount(user[1].Address) + bondAcc.Permissions.Base.Set(ptypes.Bond, true) + blockCache.UpdateAccount(bondAcc) + //------------------------------ + // one bonder with permission and an input with send should pass + sendAcc := blockCache.GetAccount(user[2].Address) + sendAcc.Permissions.Base.Set(ptypes.Send, true) + blockCache.UpdateAccount(sendAcc) + tx, _ = types.NewBondTx(user[1].PubKey) + if err := tx.AddInput(blockCache, user[2].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[1].Address, 5) + tx.SignInput(chainID, 0, user[2]) + tx.SignBond(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Unexpected error", err) + } + + // reset state (we can only bond with an account once ..) + genDoc = newBaseGenDoc(PermsAllFalse, PermsAllFalse) + st = MakeGenesisState(stateDB, &genDoc) + blockCache = NewBlockCache(st) + bondAcc = blockCache.GetAccount(user[1].Address) + bondAcc.Permissions.Base.Set(ptypes.Bond, true) + blockCache.UpdateAccount(bondAcc) + //------------------------------ + // one bonder with permission and an input with bond should pass + sendAcc.Permissions.Base.Set(ptypes.Bond, true) + blockCache.UpdateAccount(sendAcc) + tx, _ = types.NewBondTx(user[1].PubKey) + if err := tx.AddInput(blockCache, user[2].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[1].Address, 5) + tx.SignInput(chainID, 0, user[2]) + tx.SignBond(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Unexpected error", err) + } + + // reset state (we can only bond with an account once ..) + genDoc = newBaseGenDoc(PermsAllFalse, PermsAllFalse) + st = MakeGenesisState(stateDB, &genDoc) + blockCache = NewBlockCache(st) + bondAcc = blockCache.GetAccount(user[1].Address) + bondAcc.Permissions.Base.Set(ptypes.Bond, true) + blockCache.UpdateAccount(bondAcc) + //------------------------------ + // one bonder with permission and an input from that bonder and an input without send or bond should fail + tx, _ = types.NewBondTx(user[1].PubKey) + if err := tx.AddInput(blockCache, user[1].PubKey, 5); err != nil { + t.Fatal(err) + } + if err := tx.AddInput(blockCache, user[2].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[1].Address, 5) + tx.SignInput(chainID, 0, user[1]) + tx.SignInput(chainID, 1, user[2]) + tx.SignBond(chainID, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } +} + +func TestCreateAccountPermission(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[0].Permissions.Base.Set(ptypes.Send, true) // give the 0 account permission + genDoc.Accounts[1].Permissions.Base.Set(ptypes.Send, true) // give the 0 account permission + genDoc.Accounts[0].Permissions.Base.Set(ptypes.CreateAccount, true) // give the 0 account permission + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //---------------------------------------------------------- + // SendTx to unknown account + + // A single input, having the permission, should succeed + tx := types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[6].Address, 5) + tx.SignInput(chainID, 0, user[0]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Transaction failed", err) + } + + // Two inputs, both with send, one with create, one without, should fail + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + if err := tx.AddInput(blockCache, user[1].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[7].Address, 10) + tx.SignInput(chainID, 0, user[0]) + tx.SignInput(chainID, 1, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // Two inputs, both with send, one with create, one without, two ouputs (one known, one unknown) should fail + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + if err := tx.AddInput(blockCache, user[1].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[7].Address, 4) + tx.AddOutput(user[4].Address, 6) + tx.SignInput(chainID, 0, user[0]) + tx.SignInput(chainID, 1, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err == nil { + t.Fatal("Expected error") + } else { + fmt.Println(err) + } + + // Two inputs, both with send, both with create, should pass + acc := blockCache.GetAccount(user[1].Address) + acc.Permissions.Base.Set(ptypes.CreateAccount, true) + blockCache.UpdateAccount(acc) + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + if err := tx.AddInput(blockCache, user[1].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[7].Address, 10) + tx.SignInput(chainID, 0, user[0]) + tx.SignInput(chainID, 1, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Unexpected error", err) + } + + // Two inputs, both with send, both with create, two outputs (one known, one unknown) should pass + tx = types.NewSendTx() + if err := tx.AddInput(blockCache, user[0].PubKey, 5); err != nil { + t.Fatal(err) + } + if err := tx.AddInput(blockCache, user[1].PubKey, 5); err != nil { + t.Fatal(err) + } + tx.AddOutput(user[7].Address, 7) + tx.AddOutput(user[4].Address, 3) + tx.SignInput(chainID, 0, user[0]) + tx.SignInput(chainID, 1, user[1]) + if err := ExecTx(blockCache, tx, true, nil); err != nil { + t.Fatal("Unexpected error", err) + } + + //---------------------------------------------------------- + // CALL to unknown account + + acc = blockCache.GetAccount(user[0].Address) + acc.Permissions.Base.Set(ptypes.Call, true) + blockCache.UpdateAccount(acc) + + // call to contract that calls unknown account - without create_account perm + // create contract that calls the simple contract + contractCode := callContractCode(user[9].Address) + caller1ContractAddr := NewContractAddress(user[4].Address, 101) + caller1Acc := &acm.Account{ + Address: caller1ContractAddr, + Balance: 0, + Code: contractCode, + Sequence: 0, + StorageRoot: Zero256.Bytes(), + Permissions: ptypes.ZeroAccountPermissions, + } + blockCache.UpdateAccount(caller1Acc) + + // A single input, having the permission, but the contract doesn't have permission + txCall, _ := types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) + txCall.Sign(chainID, user[0]) + + // we need to subscribe to the Call event to detect the exception + _, exception := execTxWaitEvent(t, blockCache, txCall, types.EventStringAccCall(caller1ContractAddr)) // + if exception == "" { + t.Fatal("Expected exception") + } + + // NOTE: for a contract to be able to CreateAccount, it must be able to call + // NOTE: for a user to be able to CreateAccount, it must be able to send! + caller1Acc.Permissions.Base.Set(ptypes.CreateAccount, true) + caller1Acc.Permissions.Base.Set(ptypes.Call, true) + blockCache.UpdateAccount(caller1Acc) + // A single input, having the permission, but the contract doesn't have permission + txCall, _ = types.NewCallTx(blockCache, user[0].PubKey, caller1ContractAddr, nil, 100, 10000, 100) + txCall.Sign(chainID, user[0]) + + // we need to subscribe to the Call event to detect the exception + _, exception = execTxWaitEvent(t, blockCache, txCall, types.EventStringAccCall(caller1ContractAddr)) // + if exception != "" { + t.Fatal("Unexpected exception", exception) + } + +} + +// holla at my boy +var DougAddress = append([]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, []byte("THISISDOUG")...) + +func TestSNativeCALL(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[0].Permissions.Base.Set(ptypes.Call, true) // give the 0 account permission + genDoc.Accounts[3].Permissions.Base.Set(ptypes.Bond, true) // some arbitrary permission to play with + genDoc.Accounts[3].Permissions.AddRole("bumble") + genDoc.Accounts[3].Permissions.AddRole("bee") + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //---------------------------------------------------------- + // Test CALL to SNative contracts + + // make the main contract once + doug := &acm.Account{ + Address: DougAddress, + Balance: 0, + Code: nil, + Sequence: 0, + StorageRoot: Zero256.Bytes(), + Permissions: ptypes.ZeroAccountPermissions, + } + doug.Permissions.Base.Set(ptypes.Call, true) + //doug.Permissions.Base.Set(ptypes.HasBase, true) + blockCache.UpdateAccount(doug) + + fmt.Println("\n#### HasBase") + // HasBase + snativeAddress, data := snativePermTestInputCALL("has_base", user[3], ptypes.Bond, false) + testSNativeCALLExpectFail(t, blockCache, doug, snativeAddress, data) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + // return value should be true or false as a 32 byte array... + if !IsZeros(ret[:31]) || ret[31] != byte(1) { + return fmt.Errorf("Expected 1. Got %X", ret) + } + return nil + }) + + fmt.Println("\n#### SetBase") + // SetBase + snativeAddress, data = snativePermTestInputCALL("set_base", user[3], ptypes.Bond, false) + testSNativeCALLExpectFail(t, blockCache, doug, snativeAddress, data) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { return nil }) + snativeAddress, data = snativePermTestInputCALL("has_base", user[3], ptypes.Bond, false) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + // return value should be true or false as a 32 byte array... + if !IsZeros(ret) { + return fmt.Errorf("Expected 0. Got %X", ret) + } + return nil + }) + snativeAddress, data = snativePermTestInputCALL("set_base", user[3], ptypes.CreateContract, true) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { return nil }) + snativeAddress, data = snativePermTestInputCALL("has_base", user[3], ptypes.CreateContract, false) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + // return value should be true or false as a 32 byte array... + if !IsZeros(ret[:31]) || ret[31] != byte(1) { + return fmt.Errorf("Expected 1. Got %X", ret) + } + return nil + }) + + fmt.Println("\n#### UnsetBase") + // UnsetBase + snativeAddress, data = snativePermTestInputCALL("unset_base", user[3], ptypes.CreateContract, false) + testSNativeCALLExpectFail(t, blockCache, doug, snativeAddress, data) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { return nil }) + snativeAddress, data = snativePermTestInputCALL("has_base", user[3], ptypes.CreateContract, false) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + if !IsZeros(ret) { + return fmt.Errorf("Expected 0. Got %X", ret) + } + return nil + }) + + fmt.Println("\n#### SetGlobal") + // SetGlobalPerm + snativeAddress, data = snativePermTestInputCALL("set_global", user[3], ptypes.CreateContract, true) + testSNativeCALLExpectFail(t, blockCache, doug, snativeAddress, data) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { return nil }) + snativeAddress, data = snativePermTestInputCALL("has_base", user[3], ptypes.CreateContract, false) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + // return value should be true or false as a 32 byte array... + if !IsZeros(ret[:31]) || ret[31] != byte(1) { + return fmt.Errorf("Expected 1. Got %X", ret) + } + return nil + }) + + fmt.Println("\n#### HasRole") + // HasRole + snativeAddress, data = snativeRoleTestInputCALL("has_role", user[3], "bumble") + testSNativeCALLExpectFail(t, blockCache, doug, snativeAddress, data) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + if !IsZeros(ret[:31]) || ret[31] != byte(1) { + return fmt.Errorf("Expected 1. Got %X", ret) + } + return nil + }) + + fmt.Println("\n#### AddRole") + // AddRole + snativeAddress, data = snativeRoleTestInputCALL("has_role", user[3], "chuck") + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + if !IsZeros(ret) { + return fmt.Errorf("Expected 0. Got %X", ret) + } + return nil + }) + snativeAddress, data = snativeRoleTestInputCALL("add_role", user[3], "chuck") + testSNativeCALLExpectFail(t, blockCache, doug, snativeAddress, data) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { return nil }) + snativeAddress, data = snativeRoleTestInputCALL("has_role", user[3], "chuck") + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + if !IsZeros(ret[:31]) || ret[31] != byte(1) { + return fmt.Errorf("Expected 1. Got %X", ret) + } + return nil + }) + + fmt.Println("\n#### RmRole") + // RmRole + snativeAddress, data = snativeRoleTestInputCALL("rm_role", user[3], "chuck") + testSNativeCALLExpectFail(t, blockCache, doug, snativeAddress, data) + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { return nil }) + snativeAddress, data = snativeRoleTestInputCALL("has_role", user[3], "chuck") + testSNativeCALLExpectPass(t, blockCache, doug, snativeAddress, data, func(ret []byte) error { + if !IsZeros(ret) { + return fmt.Errorf("Expected 0. Got %X", ret) + } + return nil + }) +} + +func TestSNativeTx(t *testing.T) { + stateDB := dbm.GetDB("state") + genDoc := newBaseGenDoc(PermsAllFalse, PermsAllFalse) + genDoc.Accounts[0].Permissions.Base.Set(ptypes.Call, true) // give the 0 account permission + genDoc.Accounts[3].Permissions.Base.Set(ptypes.Bond, true) // some arbitrary permission to play with + genDoc.Accounts[3].Permissions.AddRole("bumble") + genDoc.Accounts[3].Permissions.AddRole("bee") + st := MakeGenesisState(stateDB, &genDoc) + blockCache := NewBlockCache(st) + + //---------------------------------------------------------- + // Test SNativeTx + + fmt.Println("\n#### SetBase") + // SetBase + snativeArgs := snativePermTestInputTx("set_base", user[3], ptypes.Bond, false) + testSNativeTxExpectFail(t, blockCache, snativeArgs) + testSNativeTxExpectPass(t, blockCache, ptypes.SetBase, snativeArgs) + acc := blockCache.GetAccount(user[3].Address) + if v, _ := acc.Permissions.Base.Get(ptypes.Bond); v { + t.Fatal("expected permission to be set false") + } + snativeArgs = snativePermTestInputTx("set_base", user[3], ptypes.CreateContract, true) + testSNativeTxExpectPass(t, blockCache, ptypes.SetBase, snativeArgs) + acc = blockCache.GetAccount(user[3].Address) + if v, _ := acc.Permissions.Base.Get(ptypes.CreateContract); !v { + t.Fatal("expected permission to be set true") + } + + fmt.Println("\n#### UnsetBase") + // UnsetBase + snativeArgs = snativePermTestInputTx("unset_base", user[3], ptypes.CreateContract, false) + testSNativeTxExpectFail(t, blockCache, snativeArgs) + testSNativeTxExpectPass(t, blockCache, ptypes.UnsetBase, snativeArgs) + acc = blockCache.GetAccount(user[3].Address) + if v, _ := acc.Permissions.Base.Get(ptypes.CreateContract); v { + t.Fatal("expected permission to be set false") + } + + fmt.Println("\n#### SetGlobal") + // SetGlobalPerm + snativeArgs = snativePermTestInputTx("set_global", user[3], ptypes.CreateContract, true) + testSNativeTxExpectFail(t, blockCache, snativeArgs) + testSNativeTxExpectPass(t, blockCache, ptypes.SetGlobal, snativeArgs) + acc = blockCache.GetAccount(ptypes.GlobalPermissionsAddress) + if v, _ := acc.Permissions.Base.Get(ptypes.CreateContract); !v { + t.Fatal("expected permission to be set true") + } + + fmt.Println("\n#### AddRole") + // AddRole + snativeArgs = snativeRoleTestInputTx("add_role", user[3], "chuck") + testSNativeTxExpectFail(t, blockCache, snativeArgs) + testSNativeTxExpectPass(t, blockCache, ptypes.AddRole, snativeArgs) + acc = blockCache.GetAccount(user[3].Address) + if v := acc.Permissions.HasRole("chuck"); !v { + t.Fatal("expected role to be added") + } + + fmt.Println("\n#### RmRole") + // RmRole + snativeArgs = snativeRoleTestInputTx("rm_role", user[3], "chuck") + testSNativeTxExpectFail(t, blockCache, snativeArgs) + testSNativeTxExpectPass(t, blockCache, ptypes.RmRole, snativeArgs) + acc = blockCache.GetAccount(user[3].Address) + if v := acc.Permissions.HasRole("chuck"); v { + t.Fatal("expected role to be removed") + } +} + +//------------------------------------------------------------------------------------- +// helpers + +var ExceptionTimeOut = "timed out waiting for event" + +// run ExecTx and wait for the Call event on given addr +// returns the msg data and an error/exception +func execTxWaitEvent(t *testing.T, blockCache *BlockCache, tx types.Tx, eventid string) (interface{}, string) { + evsw := events.NewEventSwitch() + evsw.Start() + ch := make(chan interface{}) + evsw.AddListenerForEvent("test", eventid, func(msg types.EventData) { + ch <- msg + }) + evc := events.NewEventCache(evsw) + go func() { + if err := ExecTx(blockCache, tx, true, evc); err != nil { + ch <- err.Error() + } + evc.Flush() + }() + ticker := time.NewTicker(5 * time.Second) + var msg interface{} + select { + case msg = <-ch: + case <-ticker.C: + return nil, ExceptionTimeOut + } + + switch ev := msg.(type) { + case types.EventDataTx: + return ev, ev.Exception + case types.EventDataCall: + return ev, ev.Exception + case string: + return nil, ev + default: + return ev, "" + } +} + +// give a contract perms for an snative, call it, it calls the snative, but shouldn't have permission +func testSNativeCALLExpectFail(t *testing.T, blockCache *BlockCache, doug *acm.Account, snativeAddress, data []byte) { + testSNativeCALL(t, false, blockCache, doug, snativeAddress, data, nil) +} + +// give a contract perms for an snative, call it, it calls the snative, ensure the check funciton (f) succeeds +func testSNativeCALLExpectPass(t *testing.T, blockCache *BlockCache, doug *acm.Account, snativeAddress, data []byte, f func([]byte) error) { + testSNativeCALL(t, true, blockCache, doug, snativeAddress, data, f) +} + +func testSNativeCALL(t *testing.T, expectPass bool, blockCache *BlockCache, doug *acm.Account, snativeAddress, data []byte, f func([]byte) error) { + if expectPass { + perm, err := ptypes.PermStringToFlag(TrimmedString(snativeAddress)) + if err != nil { + t.Fatal(err) + } + doug.Permissions.Base.Set(perm, true) + } + var addr []byte + contractCode := callContractCode(snativeAddress) + doug.Code = contractCode + blockCache.UpdateAccount(doug) + addr = doug.Address + tx, _ := types.NewCallTx(blockCache, user[0].PubKey, addr, data, 100, 10000, 100) + tx.Sign(chainID, user[0]) + fmt.Println("subscribing to", types.EventStringAccCall(snativeAddress)) + ev, exception := execTxWaitEvent(t, blockCache, tx, types.EventStringAccCall(snativeAddress)) + if exception == ExceptionTimeOut { + t.Fatal("Timed out waiting for event") + } + if expectPass { + if exception != "" { + t.Fatal("Unexpected exception", exception) + } + evv := ev.(types.EventDataCall) + ret := evv.Return + if err := f(ret); err != nil { + t.Fatal(err) + } + } else { + if exception == "" { + t.Fatal("Expected exception") + } + } +} + +func testSNativeTxExpectFail(t *testing.T, blockCache *BlockCache, snativeArgs ptypes.PermArgs) { + testSNativeTx(t, false, blockCache, 0, snativeArgs) +} + +func testSNativeTxExpectPass(t *testing.T, blockCache *BlockCache, perm ptypes.PermFlag, snativeArgs ptypes.PermArgs) { + testSNativeTx(t, true, blockCache, perm, snativeArgs) +} + +func testSNativeTx(t *testing.T, expectPass bool, blockCache *BlockCache, perm ptypes.PermFlag, snativeArgs ptypes.PermArgs) { + if expectPass { + acc := blockCache.GetAccount(user[0].Address) + acc.Permissions.Base.Set(perm, true) + blockCache.UpdateAccount(acc) + } + tx, _ := types.NewPermissionsTx(blockCache, user[0].PubKey, snativeArgs) + tx.Sign(chainID, user[0]) + err := ExecTx(blockCache, tx, true, nil) + if expectPass { + if err != nil { + t.Fatal("Unexpected exception", err) + } + } else { + if err == nil { + t.Fatal("Expected exception") + } + } +} + +func boolToWord256(v bool) Word256 { + var vint byte + if v { + vint = 0x1 + } else { + vint = 0x0 + } + return LeftPadWord256([]byte{vint}) +} + +func snativePermTestInputCALL(name string, user *acm.PrivAccount, perm ptypes.PermFlag, val bool) (addr []byte, data []byte) { + addr = LeftPadWord256([]byte(name)).Postfix(20) + switch name { + case "has_base", "unset_base": + data = LeftPadBytes(user.Address, 32) + data = append(data, Uint64ToWord256(uint64(perm)).Bytes()...) + case "set_base": + data = LeftPadBytes(user.Address, 32) + data = append(data, Uint64ToWord256(uint64(perm)).Bytes()...) + data = append(data, boolToWord256(val).Bytes()...) + case "set_global": + data = Uint64ToWord256(uint64(perm)).Bytes() + data = append(data, boolToWord256(val).Bytes()...) + } + return +} + +func snativePermTestInputTx(name string, user *acm.PrivAccount, perm ptypes.PermFlag, val bool) (snativeArgs ptypes.PermArgs) { + switch name { + case "has_base": + snativeArgs = &ptypes.HasBaseArgs{user.Address, perm} + case "unset_base": + snativeArgs = &ptypes.UnsetBaseArgs{user.Address, perm} + case "set_base": + snativeArgs = &ptypes.SetBaseArgs{user.Address, perm, val} + case "set_global": + snativeArgs = &ptypes.SetGlobalArgs{perm, val} + } + return +} + +func snativeRoleTestInputCALL(name string, user *acm.PrivAccount, role string) (addr []byte, data []byte) { + addr = LeftPadWord256([]byte(name)).Postfix(20) + data = LeftPadBytes(user.Address, 32) + data = append(data, LeftPadBytes([]byte(role), 32)...) + return +} + +func snativeRoleTestInputTx(name string, user *acm.PrivAccount, role string) (snativeArgs ptypes.PermArgs) { + switch name { + case "has_role": + snativeArgs = &ptypes.HasRoleArgs{user.Address, role} + case "add_role": + snativeArgs = &ptypes.AddRoleArgs{user.Address, role} + case "rm_role": + snativeArgs = &ptypes.RmRoleArgs{user.Address, role} + } + return +} + +// convenience function for contract that calls a given address +func callContractCode(contractAddr []byte) []byte { + // calldatacopy into mem and use as input to call + memOff, inputOff := byte(0x0), byte(0x0) + contractCode := []byte{0x36, 0x60, inputOff, 0x60, memOff, 0x37} + + gas1, gas2 := byte(0x1), byte(0x1) + value := byte(0x1) + inOff := byte(0x0) + retOff, retSize := byte(0x0), byte(0x20) + // this is the code we want to run (call a contract and return) + contractCode = append(contractCode, []byte{0x60, retSize, 0x60, retOff, 0x36, 0x60, inOff, 0x60, value, 0x73}...) + contractCode = append(contractCode, contractAddr...) + contractCode = append(contractCode, []byte{0x61, gas1, gas2, 0xf1, 0x60, 0x20, 0x60, 0x0, 0xf3}...) + return contractCode +} + +// convenience function for contract that is a factory for the code that comes as call data +func createContractCode() []byte { + // TODO: gas ... + + // calldatacopy the calldatasize + memOff, inputOff := byte(0x0), byte(0x0) + contractCode := []byte{0x60, memOff, 0x60, inputOff, 0x36, 0x37} + + // create + value := byte(0x1) + contractCode = append(contractCode, []byte{0x60, value, 0x36, 0x60, memOff, 0xf0}...) + return contractCode +} + +// wrap a contract in create code +func wrapContractForCreate(contractCode []byte) []byte { + // the is the code we need to return the contractCode when the contract is initialized + lenCode := len(contractCode) + // push code to the stack + code := append([]byte{0x7f}, RightPadWord256(contractCode).Bytes()...) + // store it in memory + code = append(code, []byte{0x60, 0x0, 0x52}...) + // return whats in memory + code = append(code, []byte{0x60, byte(lenCode), 0x60, 0x0, 0xf3}...) + // return init code, contract code, expected return + return code +} diff --git a/state/state.go b/state/state.go new file mode 100644 index 0000000000000000000000000000000000000000..fa1fb628ab9175bd1b28ca2ed806dafbff1b644c --- /dev/null +++ b/state/state.go @@ -0,0 +1,489 @@ +package state + +import ( + "bytes" + "io" + "io/ioutil" + "time" + + acm "github.com/eris-ltd/eris-db/account" + ptypes "github.com/eris-ltd/eris-db/permission/types" + . "github.com/eris-ltd/eris-db/state/types" + txs "github.com/eris-ltd/eris-db/txs" + + . "github.com/tendermint/go-common" + dbm "github.com/tendermint/go-db" + "github.com/tendermint/go-merkle" + "github.com/tendermint/go-wire" + + "github.com/tendermint/tendermint/events" + "github.com/tendermint/tendermint/types" +) + +var ( + stateKey = []byte("stateKey") + minBondAmount = int64(1) // TODO adjust + defaultAccountsCacheCapacity = 1000 // TODO adjust + unbondingPeriodBlocks = int(60 * 24 * 365) // TODO probably better to make it time based. + validatorTimeoutBlocks = int(10) // TODO adjust + maxLoadStateElementSize = 0 // no max +) + +//----------------------------------------------------------------------------- + +// NOTE: not goroutine-safe. +type State struct { + DB dbm.DB + ChainID string + LastBlockHeight int + LastBlockHash []byte + LastBlockParts types.PartSetHeader + LastBlockTime time.Time + BondedValidators *types.ValidatorSet + LastBondedValidators *types.ValidatorSet + UnbondingValidators *types.ValidatorSet + accounts merkle.Tree // Shouldn't be accessed directly. + validatorInfos merkle.Tree // Shouldn't be accessed directly. + nameReg merkle.Tree // Shouldn't be accessed directly. + + evc events.Fireable // typically an events.EventCache +} + +func LoadState(db dbm.DB) *State { + s := &State{DB: db} + buf := db.Get(stateKey) + if len(buf) == 0 { + return nil + } else { + r, n, err := bytes.NewReader(buf), new(int), new(error) + s.ChainID = wire.ReadString(r, maxLoadStateElementSize, n, err) + s.LastBlockHeight = wire.ReadVarint(r, n, err) + s.LastBlockHash = wire.ReadByteSlice(r, maxLoadStateElementSize, n, err) + s.LastBlockParts = wire.ReadBinary(types.PartSetHeader{}, r, maxLoadStateElementSize, n, err).(types.PartSetHeader) + s.LastBlockTime = wire.ReadTime(r, n, err) + s.BondedValidators = wire.ReadBinary(&types.ValidatorSet{}, r, maxLoadStateElementSize, n, err).(*types.ValidatorSet) + s.LastBondedValidators = wire.ReadBinary(&types.ValidatorSet{}, r, maxLoadStateElementSize, n, err).(*types.ValidatorSet) + s.UnbondingValidators = wire.ReadBinary(&types.ValidatorSet{}, r, maxLoadStateElementSize, n, err).(*types.ValidatorSet) + accountsHash := wire.ReadByteSlice(r, maxLoadStateElementSize, n, err) + s.accounts = merkle.NewIAVLTree(wire.BasicCodec, acm.AccountCodec, defaultAccountsCacheCapacity, db) + s.accounts.Load(accountsHash) + //validatorInfosHash := wire.ReadByteSlice(r, maxLoadStateElementSize, n, err) + //s.validatorInfos = merkle.NewIAVLTree(wire.BasicCodec, types.ValidatorInfoCodec, 0, db) + //s.validatorInfos.Load(validatorInfosHash) + nameRegHash := wire.ReadByteSlice(r, maxLoadStateElementSize, n, err) + s.nameReg = merkle.NewIAVLTree(wire.BasicCodec, NameRegCodec, 0, db) + s.nameReg.Load(nameRegHash) + if *err != nil { + // DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED + Exit(Fmt("Data has been corrupted or its spec has changed: %v\n", *err)) + } + // TODO: ensure that buf is completely read. + } + return s +} + +func (s *State) Save() { + s.accounts.Save() + //s.validatorInfos.Save() + s.nameReg.Save() + buf, n, err := new(bytes.Buffer), new(int), new(error) + wire.WriteString(s.ChainID, buf, n, err) + wire.WriteVarint(s.LastBlockHeight, buf, n, err) + wire.WriteByteSlice(s.LastBlockHash, buf, n, err) + wire.WriteBinary(s.LastBlockParts, buf, n, err) + wire.WriteTime(s.LastBlockTime, buf, n, err) + wire.WriteBinary(s.BondedValidators, buf, n, err) + wire.WriteBinary(s.LastBondedValidators, buf, n, err) + wire.WriteBinary(s.UnbondingValidators, buf, n, err) + wire.WriteByteSlice(s.accounts.Hash(), buf, n, err) + //wire.WriteByteSlice(s.validatorInfos.Hash(), buf, n, err) + wire.WriteByteSlice(s.nameReg.Hash(), buf, n, err) + if *err != nil { + PanicCrisis(*err) + } + s.DB.Set(stateKey, buf.Bytes()) +} + +// CONTRACT: +// Copy() is a cheap way to take a snapshot, +// as if State were copied by value. +func (s *State) Copy() *State { + return &State{ + DB: s.DB, + ChainID: s.ChainID, + LastBlockHeight: s.LastBlockHeight, + LastBlockHash: s.LastBlockHash, + LastBlockParts: s.LastBlockParts, + LastBlockTime: s.LastBlockTime, + BondedValidators: s.BondedValidators.Copy(), // TODO remove need for Copy() here. + LastBondedValidators: s.LastBondedValidators.Copy(), // That is, make updates to the validator set + UnbondingValidators: s.UnbondingValidators.Copy(), // copy the valSet lazily. + accounts: s.accounts.Copy(), + //validatorInfos: s.validatorInfos.Copy(), + nameReg: s.nameReg.Copy(), + evc: nil, + } +} + +// Returns a hash that represents the state data, excluding Last* +func (s *State) Hash() []byte { + return merkle.SimpleHashFromMap(map[string]interface{}{ + "BondedValidators": s.BondedValidators, + "UnbondingValidators": s.UnbondingValidators, + "Accounts": s.accounts, + //"ValidatorInfos": s.validatorInfos, + "NameRegistry": s.nameReg, + }) +} + +/* //XXX Done by tendermint core +// Mutates the block in place and updates it with new state hash. +func (s *State) ComputeBlockStateHash(block *types.Block) error { + sCopy := s.Copy() + // sCopy has no event cache in it, so this won't fire events + err := execBlock(sCopy, block, types.PartSetHeader{}) + if err != nil { + return err + } + // Set block.StateHash + block.StateHash = sCopy.Hash() + return nil +} +*/ + +func (s *State) SetDB(db dbm.DB) { + s.DB = db +} + +//------------------------------------- +// State.params + +func (s *State) GetGasLimit() int64 { + return 1000000 // TODO +} + +// State.params +//------------------------------------- +// State.accounts + +// Returns nil if account does not exist with given address. +// The returned Account is a copy, so mutating it +// has no side effects. +// Implements Statelike +func (s *State) GetAccount(address []byte) *acm.Account { + _, acc := s.accounts.Get(address) + if acc == nil { + return nil + } + return acc.(*acm.Account).Copy() +} + +// The account is copied before setting, so mutating it +// afterwards has no side effects. +// Implements Statelike +func (s *State) UpdateAccount(account *acm.Account) bool { + return s.accounts.Set(account.Address, account) +} + +// Implements Statelike +func (s *State) RemoveAccount(address []byte) bool { + _, removed := s.accounts.Remove(address) + return removed +} + +// The returned Account is a copy, so mutating it +// has no side effects. +func (s *State) GetAccounts() merkle.Tree { + return s.accounts.Copy() +} + +// Set the accounts tree +func (s *State) SetAccounts(accounts merkle.Tree) { + s.accounts = accounts +} + +// State.accounts +//------------------------------------- +// State.validators + +// XXX: now handled by tendermint core + +/* + +// The returned ValidatorInfo is a copy, so mutating it +// has no side effects. +func (s *State) GetValidatorInfo(address []byte) *types.ValidatorInfo { + _, valInfo := s.validatorInfos.Get(address) + if valInfo == nil { + return nil + } + return valInfo.(*types.ValidatorInfo).Copy() +} + +// Returns false if new, true if updated. +// The valInfo is copied before setting, so mutating it +// afterwards has no side effects. +func (s *State) SetValidatorInfo(valInfo *types.ValidatorInfo) (updated bool) { + return s.validatorInfos.Set(valInfo.Address, valInfo.Copy()) +} + +func (s *State) GetValidatorInfos() merkle.Tree { + return s.validatorInfos.Copy() +} + +func (s *State) unbondValidator(val *types.Validator) { + // Move validator to UnbondingValidators + val, removed := s.BondedValidators.Remove(val.Address) + if !removed { + PanicCrisis("Couldn't remove validator for unbonding") + } + val.UnbondHeight = s.LastBlockHeight + 1 + added := s.UnbondingValidators.Add(val) + if !added { + PanicCrisis("Couldn't add validator for unbonding") + } +} + +func (s *State) rebondValidator(val *types.Validator) { + // Move validator to BondingValidators + val, removed := s.UnbondingValidators.Remove(val.Address) + if !removed { + PanicCrisis("Couldn't remove validator for rebonding") + } + val.BondHeight = s.LastBlockHeight + 1 + added := s.BondedValidators.Add(val) + if !added { + PanicCrisis("Couldn't add validator for rebonding") + } +} + +func (s *State) releaseValidator(val *types.Validator) { + // Update validatorInfo + valInfo := s.GetValidatorInfo(val.Address) + if valInfo == nil { + PanicSanity("Couldn't find validatorInfo for release") + } + valInfo.ReleasedHeight = s.LastBlockHeight + 1 + s.SetValidatorInfo(valInfo) + + // Send coins back to UnbondTo outputs + accounts, err := getOrMakeOutputs(s, nil, valInfo.UnbondTo) + if err != nil { + PanicSanity("Couldn't get or make unbondTo accounts") + } + adjustByOutputs(accounts, valInfo.UnbondTo) + for _, acc := range accounts { + s.UpdateAccount(acc) + } + + // Remove validator from UnbondingValidators + _, removed := s.UnbondingValidators.Remove(val.Address) + if !removed { + PanicCrisis("Couldn't remove validator for release") + } +} + +func (s *State) destroyValidator(val *types.Validator) { + // Update validatorInfo + valInfo := s.GetValidatorInfo(val.Address) + if valInfo == nil { + PanicSanity("Couldn't find validatorInfo for release") + } + valInfo.DestroyedHeight = s.LastBlockHeight + 1 + valInfo.DestroyedAmount = val.VotingPower + s.SetValidatorInfo(valInfo) + + // Remove validator + _, removed := s.BondedValidators.Remove(val.Address) + if !removed { + _, removed := s.UnbondingValidators.Remove(val.Address) + if !removed { + PanicCrisis("Couldn't remove validator for destruction") + } + } + +} + +// Set the validator infos tree +func (s *State) SetValidatorInfos(validatorInfos merkle.Tree) { + s.validatorInfos = validatorInfos +} + +*/ + +// State.validators +//------------------------------------- +// State.storage + +func (s *State) LoadStorage(hash []byte) (storage merkle.Tree) { + storage = merkle.NewIAVLTree(wire.BasicCodec, wire.BasicCodec, 1024, s.DB) + storage.Load(hash) + return storage +} + +// State.storage +//------------------------------------- +// State.nameReg + +func (s *State) GetNameRegEntry(name string) *txs.NameRegEntry { + _, value := s.nameReg.Get(name) + if value == nil { + return nil + } + + return value.(*txs.NameRegEntry).Copy() +} + +func (s *State) UpdateNameRegEntry(entry *txs.NameRegEntry) bool { + return s.nameReg.Set(entry.Name, entry) +} + +func (s *State) RemoveNameRegEntry(name string) bool { + _, removed := s.nameReg.Remove(name) + return removed +} + +func (s *State) GetNames() merkle.Tree { + return s.nameReg.Copy() +} + +// Set the name reg tree +func (s *State) SetNameReg(nameReg merkle.Tree) { + s.nameReg = nameReg +} + +func NameRegEncoder(o interface{}, w io.Writer, n *int, err *error) { + wire.WriteBinary(o.(*txs.NameRegEntry), w, n, err) +} + +func NameRegDecoder(r io.Reader, n *int, err *error) interface{} { + return wire.ReadBinary(&txs.NameRegEntry{}, r, txs.MaxDataLength, n, err) +} + +var NameRegCodec = wire.Codec{ + Encode: NameRegEncoder, + Decode: NameRegDecoder, +} + +// State.nameReg +//------------------------------------- + +// Implements events.Eventable. Typically uses events.EventCache +func (s *State) SetFireable(evc events.Fireable) { + s.evc = evc +} + +//----------------------------------------------------------------------------- +// Genesis + +func MakeGenesisStateFromFile(db dbm.DB, genDocFile string) (*GenesisDoc, *State) { + jsonBlob, err := ioutil.ReadFile(genDocFile) + if err != nil { + Exit(Fmt("Couldn't read GenesisDoc file: %v", err)) + } + genDoc := GenesisDocFromJSON(jsonBlob) + return genDoc, MakeGenesisState(db, genDoc) +} + +func MakeGenesisState(db dbm.DB, genDoc *GenesisDoc) *State { + if len(genDoc.Validators) == 0 { + Exit(Fmt("The genesis file has no validators")) + } + + if genDoc.GenesisTime.IsZero() { + genDoc.GenesisTime = time.Now() + } + + // Make accounts state tree + accounts := merkle.NewIAVLTree(wire.BasicCodec, acm.AccountCodec, defaultAccountsCacheCapacity, db) + for _, genAcc := range genDoc.Accounts { + perm := ptypes.ZeroAccountPermissions + if genAcc.Permissions != nil { + perm = *genAcc.Permissions + } + acc := &acm.Account{ + Address: genAcc.Address, + PubKey: nil, + Sequence: 0, + Balance: genAcc.Amount, + Permissions: perm, + } + accounts.Set(acc.Address, acc) + } + + // global permissions are saved as the 0 address + // so they are included in the accounts tree + globalPerms := ptypes.DefaultAccountPermissions + if genDoc.Params != nil && genDoc.Params.GlobalPermissions != nil { + globalPerms = *genDoc.Params.GlobalPermissions + // XXX: make sure the set bits are all true + // Without it the HasPermission() functions will fail + globalPerms.Base.SetBit = ptypes.AllPermFlags + } + + permsAcc := &acm.Account{ + Address: ptypes.GlobalPermissionsAddress, + PubKey: nil, + Sequence: 0, + Balance: 1337, + Permissions: globalPerms, + } + accounts.Set(permsAcc.Address, permsAcc) + + // Make validatorInfos state tree && validators slice + /* + validatorInfos := merkle.NewIAVLTree(wire.BasicCodec, types.ValidatorInfoCodec, 0, db) + validators := make([]*types.Validator, len(genDoc.Validators)) + for i, val := range genDoc.Validators { + pubKey := val.PubKey + address := pubKey.Address() + + // Make ValidatorInfo + valInfo := &types.ValidatorInfo{ + Address: address, + PubKey: pubKey, + UnbondTo: make([]*types.TxOutput, len(val.UnbondTo)), + FirstBondHeight: 0, + FirstBondAmount: val.Amount, + } + for i, unbondTo := range val.UnbondTo { + valInfo.UnbondTo[i] = &types.TxOutput{ + Address: unbondTo.Address, + Amount: unbondTo.Amount, + } + } + validatorInfos.Set(address, valInfo) + + // Make validator + validators[i] = &types.Validator{ + Address: address, + PubKey: pubKey, + VotingPower: val.Amount, + } + } + */ + + // Make namereg tree + nameReg := merkle.NewIAVLTree(wire.BasicCodec, NameRegCodec, 0, db) + // TODO: add names, contracts to genesis.json + + // IAVLTrees must be persisted before copy operations. + accounts.Save() + //validatorInfos.Save() + nameReg.Save() + + return &State{ + DB: db, + ChainID: genDoc.ChainID, + LastBlockHeight: 0, + LastBlockHash: nil, + LastBlockParts: types.PartSetHeader{}, + LastBlockTime: genDoc.GenesisTime, + //BondedValidators: types.NewValidatorSet(validators), + //LastBondedValidators: types.NewValidatorSet(nil), + //UnbondingValidators: types.NewValidatorSet(nil), + accounts: accounts, + //validatorInfos: validatorInfos, + nameReg: nameReg, + } +} diff --git a/state/state_test.go b/state/state_test.go new file mode 100644 index 0000000000000000000000000000000000000000..9c917e78c3103755c42462fccc4f766e54e48ccd --- /dev/null +++ b/state/state_test.go @@ -0,0 +1,699 @@ +package state + +import ( + "bytes" + "testing" + "time" + + _ "github.com/tendermint/tendermint/config/tendermint_test" + "github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/account" +) + +func execTxWithState(state *State, tx types.Tx, runCall bool) error { + cache := NewBlockCache(state) + if err := ExecTx(cache, tx, runCall, nil); err != nil { + return err + } else { + cache.Sync() + return nil + } +} + +func execTxWithStateNewBlock(state *State, tx types.Tx, runCall bool) error { + if err := execTxWithState(state, tx, runCall); err != nil { + return err + } + + state.LastBlockHeight += 1 + return nil +} + +func TestCopyState(t *testing.T) { + // Generate a random state + s0, privAccounts, _ := RandGenesisState(10, true, 1000, 5, true, 1000) + s0Hash := s0.Hash() + if len(s0Hash) == 0 { + t.Error("Expected state hash") + } + + // Check hash of copy + s0Copy := s0.Copy() + if !bytes.Equal(s0Hash, s0Copy.Hash()) { + t.Error("Expected state copy hash to be the same") + } + + // Mutate the original; hash should change. + acc0Address := privAccounts[0].PubKey.Address() + acc := s0.GetAccount(acc0Address) + acc.Balance += 1 + + // The account balance shouldn't have changed yet. + if s0.GetAccount(acc0Address).Balance == acc.Balance { + t.Error("Account balance changed unexpectedly") + } + + // Setting, however, should change the balance. + s0.UpdateAccount(acc) + if s0.GetAccount(acc0Address).Balance != acc.Balance { + t.Error("Account balance wasn't set") + } + + // Now that the state changed, the hash should change too. + if bytes.Equal(s0Hash, s0.Hash()) { + t.Error("Expected state hash to have changed") + } + + // The s0Copy shouldn't have changed though. + if !bytes.Equal(s0Hash, s0Copy.Hash()) { + t.Error("Expected state copy hash to have not changed") + } +} + +func makeBlock(t *testing.T, state *State, validation *types.Validation, txs []types.Tx) *types.Block { + if validation == nil { + validation = &types.Validation{} + } + block := &types.Block{ + Header: &types.Header{ + ChainID: state.ChainID, + Height: state.LastBlockHeight + 1, + Time: state.LastBlockTime.Add(time.Minute), + Fees: 0, + NumTxs: len(txs), + LastBlockHash: state.LastBlockHash, + LastBlockParts: state.LastBlockParts, + StateHash: nil, + }, + LastValidation: validation, + Data: &types.Data{ + Txs: txs, + }, + } + block.FillHeader() + + // Fill in block StateHash + err := state.ComputeBlockStateHash(block) + if err != nil { + t.Error("Error appending initial block:", err) + } + if len(block.Header.StateHash) == 0 { + t.Error("Expected StateHash but got nothing.") + } + + return block +} + +func TestGenesisSaveLoad(t *testing.T) { + + // Generate a state, save & load it. + s0, _, _ := RandGenesisState(10, true, 1000, 5, true, 1000) + + // Make complete block and blockParts + block := makeBlock(t, s0, nil, nil) + blockParts := block.MakePartSet() + + // Now append the block to s0. + err := ExecBlock(s0, block, blockParts.Header()) + if err != nil { + t.Error("Error appending initial block:", err) + } + + // Save s0 + s0.Save() + + // Sanity check s0 + //s0.DB.(*dbm.MemDB).Print() + if s0.BondedValidators.TotalVotingPower() == 0 { + t.Error("s0 BondedValidators TotalVotingPower should not be 0") + } + if s0.LastBlockHeight != 1 { + t.Error("s0 LastBlockHeight should be 1, got", s0.LastBlockHeight) + } + + // Load s1 + s1 := LoadState(s0.DB) + + // Compare height & blockHash + if s0.LastBlockHeight != s1.LastBlockHeight { + t.Error("LastBlockHeight mismatch") + } + if !bytes.Equal(s0.LastBlockHash, s1.LastBlockHash) { + t.Error("LastBlockHash mismatch") + } + + // Compare state merkle trees + if s0.BondedValidators.Size() != s1.BondedValidators.Size() { + t.Error("BondedValidators Size mismatch") + } + if s0.BondedValidators.TotalVotingPower() != s1.BondedValidators.TotalVotingPower() { + t.Error("BondedValidators TotalVotingPower mismatch") + } + if !bytes.Equal(s0.BondedValidators.Hash(), s1.BondedValidators.Hash()) { + t.Error("BondedValidators hash mismatch") + } + if s0.UnbondingValidators.Size() != s1.UnbondingValidators.Size() { + t.Error("UnbondingValidators Size mismatch") + } + if s0.UnbondingValidators.TotalVotingPower() != s1.UnbondingValidators.TotalVotingPower() { + t.Error("UnbondingValidators TotalVotingPower mismatch") + } + if !bytes.Equal(s0.UnbondingValidators.Hash(), s1.UnbondingValidators.Hash()) { + t.Error("UnbondingValidators hash mismatch") + } + if !bytes.Equal(s0.accounts.Hash(), s1.accounts.Hash()) { + t.Error("Accounts mismatch") + } + if !bytes.Equal(s0.validatorInfos.Hash(), s1.validatorInfos.Hash()) { + t.Error("Accounts mismatch") + } +} + +func TestTxSequence(t *testing.T) { + + state, privAccounts, _ := RandGenesisState(3, true, 1000, 1, true, 1000) + acc0 := state.GetAccount(privAccounts[0].PubKey.Address()) + acc0PubKey := privAccounts[0].PubKey + acc1 := state.GetAccount(privAccounts[1].PubKey.Address()) + + // Test a variety of sequence numbers for the tx. + // The tx should only pass when i == 1. + for i := -1; i < 3; i++ { + sequence := acc0.Sequence + i + tx := types.NewSendTx() + tx.AddInputWithNonce(acc0PubKey, 1, sequence) + tx.AddOutput(acc1.Address, 1) + tx.Inputs[0].Signature = privAccounts[0].Sign(state.ChainID, tx) + stateCopy := state.Copy() + err := execTxWithState(stateCopy, tx, true) + if i == 1 { + // Sequence is good. + if err != nil { + t.Errorf("Expected good sequence to pass: %v", err) + } + // Check acc.Sequence. + newAcc0 := stateCopy.GetAccount(acc0.Address) + if newAcc0.Sequence != sequence { + t.Errorf("Expected account sequence to change to %v, got %v", + sequence, newAcc0.Sequence) + } + } else { + // Sequence is bad. + if err == nil { + t.Errorf("Expected bad sequence to fail") + } + // Check acc.Sequence. (shouldn't have changed) + newAcc0 := stateCopy.GetAccount(acc0.Address) + if newAcc0.Sequence != acc0.Sequence { + t.Errorf("Expected account sequence to not change from %v, got %v", + acc0.Sequence, newAcc0.Sequence) + } + } + } +} + +func TestNameTxs(t *testing.T) { + state, privAccounts, _ := RandGenesisState(3, true, 1000, 1, true, 1000) + + types.MinNameRegistrationPeriod = 5 + startingBlock := state.LastBlockHeight + + // try some bad names. these should all fail + names := []string{"", "\n", "123#$%", "\x00", string([]byte{20, 40, 60, 80}), "baffledbythespectacleinallofthisyouseeehesaidwithouteyessurprised", "no spaces please"} + data := "something about all this just doesn't feel right." + fee := int64(1000) + numDesiredBlocks := 5 + for _, name := range names { + amt := fee + int64(numDesiredBlocks)*types.NameByteCostMultiplier*types.NameBlockCostMultiplier*types.NameBaseCost(name, data) + tx, _ := types.NewNameTx(state, privAccounts[0].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[0]) + + if err := execTxWithState(state, tx, true); err == nil { + t.Fatalf("Expected invalid name error from %s", name) + } + } + + // try some bad data. these should all fail + name := "hold_it_chum" + datas := []string{"cold&warm", "!@#$%^&*()", "<<<>>>>", "because why would you ever need a ~ or a & or even a % in a json file? make your case and we'll talk"} + for _, data := range datas { + amt := fee + int64(numDesiredBlocks)*types.NameByteCostMultiplier*types.NameBlockCostMultiplier*types.NameBaseCost(name, data) + tx, _ := types.NewNameTx(state, privAccounts[0].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[0]) + + if err := execTxWithState(state, tx, true); err == nil { + t.Fatalf("Expected invalid data error from %s", data) + } + } + + validateEntry := func(t *testing.T, entry *types.NameRegEntry, name, data string, addr []byte, expires int) { + + if entry == nil { + t.Fatalf("Could not find name %s", name) + } + if bytes.Compare(entry.Owner, addr) != 0 { + t.Fatalf("Wrong owner. Got %X expected %X", entry.Owner, addr) + } + if data != entry.Data { + t.Fatalf("Wrong data. Got %s expected %s", entry.Data, data) + } + if name != entry.Name { + t.Fatalf("Wrong name. Got %s expected %s", entry.Name, name) + } + if expires != entry.Expires { + t.Fatalf("Wrong expiry. Got %d, expected %d", entry.Expires, expires) + } + } + + // try a good one, check data, owner, expiry + name = "@looking_good/karaoke_bar.broadband" + data = "on this side of neptune there are 1234567890 people: first is OMNIVORE+-3. Or is it. Ok this is pretty restrictive. No exclamations :(. Faces tho :')" + amt := fee + int64(numDesiredBlocks)*types.NameByteCostMultiplier*types.NameBlockCostMultiplier*types.NameBaseCost(name, data) + tx, _ := types.NewNameTx(state, privAccounts[0].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[0]) + if err := execTxWithState(state, tx, true); err != nil { + t.Fatal(err) + } + entry := state.GetNameRegEntry(name) + validateEntry(t, entry, name, data, privAccounts[0].Address, startingBlock+numDesiredBlocks) + + // fail to update it as non-owner, in same block + tx, _ = types.NewNameTx(state, privAccounts[1].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[1]) + if err := execTxWithState(state, tx, true); err == nil { + t.Fatal("Expected error") + } + + // update it as owner, just to increase expiry, in same block + // NOTE: we have to resend the data or it will clear it (is this what we want?) + tx, _ = types.NewNameTx(state, privAccounts[0].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[0]) + if err := execTxWithStateNewBlock(state, tx, true); err != nil { + t.Fatal(err) + } + entry = state.GetNameRegEntry(name) + validateEntry(t, entry, name, data, privAccounts[0].Address, startingBlock+numDesiredBlocks*2) + + // update it as owner, just to increase expiry, in next block + tx, _ = types.NewNameTx(state, privAccounts[0].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[0]) + if err := execTxWithStateNewBlock(state, tx, true); err != nil { + t.Fatal(err) + } + entry = state.GetNameRegEntry(name) + validateEntry(t, entry, name, data, privAccounts[0].Address, startingBlock+numDesiredBlocks*3) + + // fail to update it as non-owner + state.LastBlockHeight = entry.Expires - 1 + tx, _ = types.NewNameTx(state, privAccounts[1].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[1]) + if err := execTxWithState(state, tx, true); err == nil { + t.Fatal("Expected error") + } + + // once expires, non-owner succeeds + state.LastBlockHeight = entry.Expires + tx, _ = types.NewNameTx(state, privAccounts[1].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[1]) + if err := execTxWithState(state, tx, true); err != nil { + t.Fatal(err) + } + entry = state.GetNameRegEntry(name) + validateEntry(t, entry, name, data, privAccounts[1].Address, state.LastBlockHeight+numDesiredBlocks) + + // update it as new owner, with new data (longer), but keep the expiry! + data = "In the beginning there was no thing, not even the beginning. It hadn't been here, no there, nor for that matter anywhere, not especially because it had not to even exist, let alone to not. Nothing especially odd about that." + oldCredit := amt - fee + numDesiredBlocks = 10 + amt = fee + (int64(numDesiredBlocks)*types.NameByteCostMultiplier*types.NameBlockCostMultiplier*types.NameBaseCost(name, data) - oldCredit) + tx, _ = types.NewNameTx(state, privAccounts[1].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[1]) + if err := execTxWithState(state, tx, true); err != nil { + t.Fatal(err) + } + entry = state.GetNameRegEntry(name) + validateEntry(t, entry, name, data, privAccounts[1].Address, state.LastBlockHeight+numDesiredBlocks) + + // test removal + amt = fee + data = "" + tx, _ = types.NewNameTx(state, privAccounts[1].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[1]) + if err := execTxWithStateNewBlock(state, tx, true); err != nil { + t.Fatal(err) + } + entry = state.GetNameRegEntry(name) + if entry != nil { + t.Fatal("Expected removed entry to be nil") + } + + // create entry by key0, + // test removal by key1 after expiry + name = "looking_good/karaoke_bar" + data = "some data" + amt = fee + int64(numDesiredBlocks)*types.NameByteCostMultiplier*types.NameBlockCostMultiplier*types.NameBaseCost(name, data) + tx, _ = types.NewNameTx(state, privAccounts[0].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[0]) + if err := execTxWithState(state, tx, true); err != nil { + t.Fatal(err) + } + entry = state.GetNameRegEntry(name) + validateEntry(t, entry, name, data, privAccounts[0].Address, state.LastBlockHeight+numDesiredBlocks) + state.LastBlockHeight = entry.Expires + + amt = fee + data = "" + tx, _ = types.NewNameTx(state, privAccounts[1].PubKey, name, data, amt, fee) + tx.Sign(state.ChainID, privAccounts[1]) + if err := execTxWithStateNewBlock(state, tx, true); err != nil { + t.Fatal(err) + } + entry = state.GetNameRegEntry(name) + if entry != nil { + t.Fatal("Expected removed entry to be nil") + } +} + +// TODO: test overflows. +// TODO: test for unbonding validators. +func TestTxs(t *testing.T) { + + state, privAccounts, _ := RandGenesisState(3, true, 1000, 1, true, 1000) + + //val0 := state.GetValidatorInfo(privValidators[0].Address) + acc0 := state.GetAccount(privAccounts[0].PubKey.Address()) + acc0PubKey := privAccounts[0].PubKey + acc1 := state.GetAccount(privAccounts[1].PubKey.Address()) + + // SendTx. + { + state := state.Copy() + tx := &types.SendTx{ + Inputs: []*types.TxInput{ + &types.TxInput{ + Address: acc0.Address, + Amount: 1, + Sequence: acc0.Sequence + 1, + PubKey: acc0PubKey, + }, + }, + Outputs: []*types.TxOutput{ + &types.TxOutput{ + Address: acc1.Address, + Amount: 1, + }, + }, + } + + tx.Inputs[0].Signature = privAccounts[0].Sign(state.ChainID, tx) + err := execTxWithState(state, tx, true) + if err != nil { + t.Errorf("Got error in executing send transaction, %v", err) + } + newAcc0 := state.GetAccount(acc0.Address) + if acc0.Balance-1 != newAcc0.Balance { + t.Errorf("Unexpected newAcc0 balance. Expected %v, got %v", + acc0.Balance-1, newAcc0.Balance) + } + newAcc1 := state.GetAccount(acc1.Address) + if acc1.Balance+1 != newAcc1.Balance { + t.Errorf("Unexpected newAcc1 balance. Expected %v, got %v", + acc1.Balance+1, newAcc1.Balance) + } + } + + // CallTx. Just runs through it and checks the transfer. See vm, rpc tests for more + { + state := state.Copy() + newAcc1 := state.GetAccount(acc1.Address) + newAcc1.Code = []byte{0x60} + state.UpdateAccount(newAcc1) + tx := &types.CallTx{ + Input: &types.TxInput{ + Address: acc0.Address, + Amount: 1, + Sequence: acc0.Sequence + 1, + PubKey: acc0PubKey, + }, + Address: acc1.Address, + GasLimit: 10, + } + + tx.Input.Signature = privAccounts[0].Sign(state.ChainID, tx) + err := execTxWithState(state, tx, true) + if err != nil { + t.Errorf("Got error in executing call transaction, %v", err) + } + newAcc0 := state.GetAccount(acc0.Address) + if acc0.Balance-1 != newAcc0.Balance { + t.Errorf("Unexpected newAcc0 balance. Expected %v, got %v", + acc0.Balance-1, newAcc0.Balance) + } + newAcc1 = state.GetAccount(acc1.Address) + if acc1.Balance+1 != newAcc1.Balance { + t.Errorf("Unexpected newAcc1 balance. Expected %v, got %v", + acc1.Balance+1, newAcc1.Balance) + } + } + + // NameTx. + { + entryName := "satoshi" + entryData := ` +A purely peer-to-peer version of electronic cash would allow online +payments to be sent directly from one party to another without going through a +financial institution. Digital signatures provide part of the solution, but the main +benefits are lost if a trusted third party is still required to prevent double-spending. +We propose a solution to the double-spending problem using a peer-to-peer network. +The network timestamps transactions by hashing them into an ongoing chain of +hash-based proof-of-work, forming a record that cannot be changed without redoing +the proof-of-work. The longest chain not only serves as proof of the sequence of +events witnessed, but proof that it came from the largest pool of CPU power. As +long as a majority of CPU power is controlled by nodes that are not cooperating to +attack the network, they'll generate the longest chain and outpace attackers. The +network itself requires minimal structure. Messages are broadcast on a best effort +basis, and nodes can leave and rejoin the network at will, accepting the longest +proof-of-work chain as proof of what happened while they were gone ` + entryAmount := int64(10000) + + state := state.Copy() + tx := &types.NameTx{ + Input: &types.TxInput{ + Address: acc0.Address, + Amount: entryAmount, + Sequence: acc0.Sequence + 1, + PubKey: acc0PubKey, + }, + Name: entryName, + Data: entryData, + } + + tx.Input.Signature = privAccounts[0].Sign(state.ChainID, tx) + err := execTxWithState(state, tx, true) + if err != nil { + t.Errorf("Got error in executing call transaction, %v", err) + } + newAcc0 := state.GetAccount(acc0.Address) + if acc0.Balance-entryAmount != newAcc0.Balance { + t.Errorf("Unexpected newAcc0 balance. Expected %v, got %v", + acc0.Balance-entryAmount, newAcc0.Balance) + } + entry := state.GetNameRegEntry(entryName) + if entry == nil { + t.Errorf("Expected an entry but got nil") + } + if entry.Data != entryData { + t.Errorf("Wrong data stored") + } + + // test a bad string + tx.Data = string([]byte{0, 1, 2, 3, 127, 128, 129, 200, 251}) + tx.Input.Sequence += 1 + tx.Input.Signature = privAccounts[0].Sign(state.ChainID, tx) + err = execTxWithState(state, tx, true) + if _, ok := err.(types.ErrTxInvalidString); !ok { + t.Errorf("Expected invalid string error. Got: %s", err.Error()) + } + } + + // BondTx. + { + state := state.Copy() + tx := &types.BondTx{ + PubKey: acc0PubKey.(account.PubKeyEd25519), + Inputs: []*types.TxInput{ + &types.TxInput{ + Address: acc0.Address, + Amount: 1, + Sequence: acc0.Sequence + 1, + PubKey: acc0PubKey, + }, + }, + UnbondTo: []*types.TxOutput{ + &types.TxOutput{ + Address: acc0.Address, + Amount: 1, + }, + }, + } + tx.Signature = privAccounts[0].Sign(state.ChainID, tx).(account.SignatureEd25519) + tx.Inputs[0].Signature = privAccounts[0].Sign(state.ChainID, tx) + err := execTxWithState(state, tx, true) + if err != nil { + t.Errorf("Got error in executing bond transaction, %v", err) + } + newAcc0 := state.GetAccount(acc0.Address) + if newAcc0.Balance != acc0.Balance-1 { + t.Errorf("Unexpected newAcc0 balance. Expected %v, got %v", + acc0.Balance-1, newAcc0.Balance) + } + _, acc0Val := state.BondedValidators.GetByAddress(acc0.Address) + if acc0Val == nil { + t.Errorf("acc0Val not present") + } + if acc0Val.BondHeight != state.LastBlockHeight+1 { + t.Errorf("Unexpected bond height. Expected %v, got %v", + state.LastBlockHeight, acc0Val.BondHeight) + } + if acc0Val.VotingPower != 1 { + t.Errorf("Unexpected voting power. Expected %v, got %v", + acc0Val.VotingPower, acc0.Balance) + } + if acc0Val.Accum != 0 { + t.Errorf("Unexpected accum. Expected 0, got %v", + acc0Val.Accum) + } + } + + // TODO UnbondTx. + +} + +func TestSuicide(t *testing.T) { + + state, privAccounts, _ := RandGenesisState(3, true, 1000, 1, true, 1000) + + acc0 := state.GetAccount(privAccounts[0].PubKey.Address()) + acc0PubKey := privAccounts[0].PubKey + acc1 := state.GetAccount(privAccounts[1].PubKey.Address()) + acc2 := state.GetAccount(privAccounts[2].Address) + sendingAmount, refundedBalance, oldBalance := int64(1), acc1.Balance, acc2.Balance + + newAcc1 := state.GetAccount(acc1.Address) + + // store 0x1 at 0x1, push an address, then suicide :) + contractCode := []byte{0x60, 0x01, 0x60, 0x01, 0x55, 0x73} + contractCode = append(contractCode, acc2.Address...) + contractCode = append(contractCode, 0xff) + newAcc1.Code = contractCode + state.UpdateAccount(newAcc1) + + // send call tx with no data, cause suicide + tx := types.NewCallTxWithNonce(acc0PubKey, acc1.Address, nil, sendingAmount, 1000, 0, acc0.Sequence+1) + tx.Input.Signature = privAccounts[0].Sign(state.ChainID, tx) + + // we use cache instead of execTxWithState so we can run the tx twice + cache := NewBlockCache(state) + if err := ExecTx(cache, tx, true, nil); err != nil { + t.Errorf("Got error in executing call transaction, %v", err) + } + + // if we do it again, we won't get an error, but the suicide + // shouldn't happen twice and the caller should lose fee + tx.Input.Sequence += 1 + tx.Input.Signature = privAccounts[0].Sign(state.ChainID, tx) + if err := ExecTx(cache, tx, true, nil); err != nil { + t.Errorf("Got error in executing call transaction, %v", err) + } + + // commit the block + cache.Sync() + + // acc2 should receive the sent funds and the contracts balance + newAcc2 := state.GetAccount(acc2.Address) + newBalance := sendingAmount + refundedBalance + oldBalance + if newAcc2.Balance != newBalance { + t.Errorf("Unexpected newAcc2 balance. Expected %v, got %v", + newAcc2.Balance, newBalance) + } + newAcc1 = state.GetAccount(acc1.Address) + if newAcc1 != nil { + t.Errorf("Expected account to be removed") + } + +} + +func TestAddValidator(t *testing.T) { + + // Generate a state, save & load it. + s0, privAccounts, privValidators := RandGenesisState(10, false, 1000, 1, false, 1000) + + // The first privAccount will become a validator + acc0 := privAccounts[0] + bondTx := &types.BondTx{ + PubKey: acc0.PubKey.(account.PubKeyEd25519), + Inputs: []*types.TxInput{ + &types.TxInput{ + Address: acc0.Address, + Amount: 1000, + Sequence: 1, + PubKey: acc0.PubKey, + }, + }, + UnbondTo: []*types.TxOutput{ + &types.TxOutput{ + Address: acc0.Address, + Amount: 1000, + }, + }, + } + bondTx.Signature = acc0.Sign(s0.ChainID, bondTx).(account.SignatureEd25519) + bondTx.Inputs[0].Signature = acc0.Sign(s0.ChainID, bondTx) + + // Make complete block and blockParts + block0 := makeBlock(t, s0, nil, []types.Tx{bondTx}) + block0Parts := block0.MakePartSet() + + // Sanity check + if s0.BondedValidators.Size() != 1 { + t.Error("Expected there to be 1 validators before bondTx") + } + + // Now append the block to s0. + err := ExecBlock(s0, block0, block0Parts.Header()) + if err != nil { + t.Error("Error appending initial block:", err) + } + + // Must save before further modification + s0.Save() + + // Test new validator set + if s0.BondedValidators.Size() != 2 { + t.Error("Expected there to be 2 validators after bondTx") + } + + // The validation for the next block should only require 1 signature + // (the new validator wasn't active for block0) + precommit0 := &types.Vote{ + Height: 1, + Round: 0, + Type: types.VoteTypePrecommit, + BlockHash: block0.Hash(), + BlockPartsHeader: block0Parts.Header(), + } + privValidators[0].SignVote(s0.ChainID, precommit0) + + block1 := makeBlock(t, s0, + &types.Validation{ + Precommits: []*types.Vote{ + precommit0, + }, + }, nil, + ) + block1Parts := block1.MakePartSet() + err = ExecBlock(s0, block1, block1Parts.Header()) + if err != nil { + t.Error("Error appending secondary block:", err) + } +} diff --git a/state/test.go b/state/test.go new file mode 100644 index 0000000000000000000000000000000000000000..49d6dd28d8647a023c7deeb5e0b2d85e351ac5d8 --- /dev/null +++ b/state/test.go @@ -0,0 +1,76 @@ +package state + +import ( + "sort" + "time" + + . "github.com/tendermint/go-common" + dbm "github.com/tendermint/go-db" + "github.com/tendermint/tendermint/types" + acm "github.com/eris-ltd/eris-db/account" + ptypes "github.com/eris-ltd/eris-db/permission/types" + . "github.com/eris-ltd/eris-db/state/types" +) + +func RandAccount(randBalance bool, minBalance int64) (*acm.Account, *acm.PrivAccount) { + privAccount := acm.GenPrivAccount() + perms := ptypes.DefaultAccountPermissions + acc := &acm.Account{ + Address: privAccount.PubKey.Address(), + PubKey: privAccount.PubKey, + Sequence: RandInt(), + Balance: minBalance, + Permissions: perms, + } + if randBalance { + acc.Balance += int64(RandUint32()) + } + return acc, privAccount +} + +func RandGenesisDoc(numAccounts int, randBalance bool, minBalance int64, numValidators int, randBonded bool, minBonded int64) (*GenesisDoc, []*acm.PrivAccount, []*types.PrivValidator) { + accounts := make([]GenesisAccount, numAccounts) + privAccounts := make([]*acm.PrivAccount, numAccounts) + defaultPerms := ptypes.DefaultAccountPermissions + for i := 0; i < numAccounts; i++ { + account, privAccount := RandAccount(randBalance, minBalance) + accounts[i] = GenesisAccount{ + Address: account.Address, + Amount: account.Balance, + Permissions: &defaultPerms, // This will get copied into each state.Account. + } + privAccounts[i] = privAccount + } + validators := make([]GenesisValidator, numValidators) + privValidators := make([]*types.PrivValidator, numValidators) + for i := 0; i < numValidators; i++ { + val, privVal := types.RandValidator(randBonded, minBonded) + validators[i] = GenesisValidator{ + PubKey: val.PubKey, + Amount: val.VotingPower, + UnbondTo: []BasicAccount{ + { + Address: val.PubKey.Address(), + Amount: val.VotingPower, + }, + }, + } + privValidators[i] = privVal + } + sort.Sort(types.PrivValidatorsByAddress(privValidators)) + return &GenesisDoc{ + GenesisTime: time.Now(), + ChainID: "tendermint_test", + Accounts: accounts, + Validators: validators, + }, privAccounts, privValidators + +} + +func RandGenesisState(numAccounts int, randBalance bool, minBalance int64, numValidators int, randBonded bool, minBonded int64) (*State, []*acm.PrivAccount, []*types.PrivValidator) { + db := dbm.NewMemDB() + genDoc, privAccounts, privValidators := RandGenesisDoc(numAccounts, randBalance, minBalance, numValidators, randBonded, minBonded) + s0 := MakeGenesisState(db, genDoc) + s0.Save() + return s0, privAccounts, privValidators +} diff --git a/state/tx_cache.go b/state/tx_cache.go new file mode 100644 index 0000000000000000000000000000000000000000..b3ed160c902fce5129b3648bf5044e5ee845bb15 --- /dev/null +++ b/state/tx_cache.go @@ -0,0 +1,199 @@ +package state + +import ( + acm "github.com/eris-ltd/eris-db/account" + "github.com/eris-ltd/eris-db/evm" + ptypes "github.com/eris-ltd/eris-db/permission/types" // for GlobalPermissionAddress ... + "github.com/eris-ltd/eris-db/txs" + + . "github.com/tendermint/go-common" +) + +type TxCache struct { + backend *BlockCache + accounts map[Word256]vmAccountInfo + storages map[Tuple256]Word256 +} + +func NewTxCache(backend *BlockCache) *TxCache { + return &TxCache{ + backend: backend, + accounts: make(map[Word256]vmAccountInfo), + storages: make(map[Tuple256]Word256), + } +} + +//------------------------------------- +// TxCache.account + +func (cache *TxCache) GetAccount(addr Word256) *vm.Account { + acc, removed := cache.accounts[addr].unpack() + if removed { + return nil + } else if acc == nil { + acc2 := cache.backend.GetAccount(addr.Postfix(20)) + if acc2 != nil { + return toVMAccount(acc2) + } + } + return acc +} + +func (cache *TxCache) UpdateAccount(acc *vm.Account) { + addr := acc.Address + _, removed := cache.accounts[addr].unpack() + if removed { + PanicSanity("UpdateAccount on a removed account") + } + cache.accounts[addr] = vmAccountInfo{acc, false} +} + +func (cache *TxCache) RemoveAccount(acc *vm.Account) { + addr := acc.Address + _, removed := cache.accounts[addr].unpack() + if removed { + PanicSanity("RemoveAccount on a removed account") + } + cache.accounts[addr] = vmAccountInfo{acc, true} +} + +// Creates a 20 byte address and bumps the creator's nonce. +func (cache *TxCache) CreateAccount(creator *vm.Account) *vm.Account { + + // Generate an address + nonce := creator.Nonce + creator.Nonce += 1 + + addr := LeftPadWord256(NewContractAddress(creator.Address.Postfix(20), int(nonce))) + + // Create account from address. + account, removed := cache.accounts[addr].unpack() + if removed || account == nil { + account = &vm.Account{ + Address: addr, + Balance: 0, + Code: nil, + Nonce: 0, + Permissions: cache.GetAccount(ptypes.GlobalPermissionsAddress256).Permissions, + Other: vmAccountOther{ + PubKey: nil, + StorageRoot: nil, + }, + } + cache.accounts[addr] = vmAccountInfo{account, false} + return account + } else { + // either we've messed up nonce handling, or sha3 is broken + PanicSanity(Fmt("Could not create account, address already exists: %X", addr)) + return nil + } +} + +// TxCache.account +//------------------------------------- +// TxCache.storage + +func (cache *TxCache) GetStorage(addr Word256, key Word256) Word256 { + // Check cache + value, ok := cache.storages[Tuple256{addr, key}] + if ok { + return value + } + + // Load from backend + return cache.backend.GetStorage(addr, key) +} + +// NOTE: Set value to zero to removed from the trie. +func (cache *TxCache) SetStorage(addr Word256, key Word256, value Word256) { + _, removed := cache.accounts[addr].unpack() + if removed { + PanicSanity("SetStorage() on a removed account") + } + cache.storages[Tuple256{addr, key}] = value +} + +// TxCache.storage +//------------------------------------- + +// These updates do not have to be in deterministic order, +// the backend is responsible for ordering updates. +func (cache *TxCache) Sync() { + + // Remove or update storage + for addrKey, value := range cache.storages { + addr, key := Tuple256Split(addrKey) + cache.backend.SetStorage(addr, key, value) + } + + // Remove or update accounts + for addr, accInfo := range cache.accounts { + acc, removed := accInfo.unpack() + if removed { + cache.backend.RemoveAccount(addr.Postfix(20)) + } else { + cache.backend.UpdateAccount(toStateAccount(acc)) + } + } +} + +//----------------------------------------------------------------------------- + +// Convenience function to return address of new contract +func NewContractAddress(caller []byte, nonce int) []byte { + return types.NewContractAddress(caller, nonce) +} + +// Converts backend.Account to vm.Account struct. +func toVMAccount(acc *acm.Account) *vm.Account { + return &vm.Account{ + Address: LeftPadWord256(acc.Address), + Balance: acc.Balance, + Code: acc.Code, // This is crazy. + Nonce: int64(acc.Sequence), + Permissions: acc.Permissions, // Copy + Other: vmAccountOther{ + PubKey: acc.PubKey, + StorageRoot: acc.StorageRoot, + }, + } +} + +// Converts vm.Account to backend.Account struct. +func toStateAccount(acc *vm.Account) *acm.Account { + var pubKey acm.PubKey + var storageRoot []byte + if acc.Other != nil { + pubKey, storageRoot = acc.Other.(vmAccountOther).unpack() + } + + return &acm.Account{ + Address: acc.Address.Postfix(20), + PubKey: pubKey, + Balance: acc.Balance, + Code: acc.Code, + Sequence: int(acc.Nonce), + StorageRoot: storageRoot, + Permissions: acc.Permissions, // Copy + } +} + +// Everything in acmAccount that doesn't belong in +// exported vmAccount fields. +type vmAccountOther struct { + PubKey acm.PubKey + StorageRoot []byte +} + +func (accOther vmAccountOther) unpack() (acm.PubKey, []byte) { + return accOther.PubKey, accOther.StorageRoot +} + +type vmAccountInfo struct { + account *vm.Account + removed bool +} + +func (accInfo vmAccountInfo) unpack() (*vm.Account, bool) { + return accInfo.account, accInfo.removed +} diff --git a/state/tx_cache_test.go b/state/tx_cache_test.go new file mode 100644 index 0000000000000000000000000000000000000000..a943ec72844fa37791c4771d78b5931231512ff4 --- /dev/null +++ b/state/tx_cache_test.go @@ -0,0 +1,22 @@ +package state + +import ( + "bytes" + "testing" + + "github.com/tendermint/go-wire" +) + +func TestStateToFromVMAccount(t *testing.T) { + acmAcc1, _ := RandAccount(true, 456) + vmAcc := toVMAccount(acmAcc1) + acmAcc2 := toStateAccount(vmAcc) + + acmAcc1Bytes := wire.BinaryBytes(acmAcc1) + acmAcc2Bytes := wire.BinaryBytes(acmAcc2) + if !bytes.Equal(acmAcc1Bytes, acmAcc2Bytes) { + t.Errorf("Unexpected account wire bytes\n%X vs\n%X", + acmAcc1Bytes, acmAcc2Bytes) + } + +} diff --git a/state/types/genesis.go b/state/types/genesis.go new file mode 100644 index 0000000000000000000000000000000000000000..8886da405c2b3b294fbfa6586b0be9d15f74a7b8 --- /dev/null +++ b/state/types/genesis.go @@ -0,0 +1,61 @@ +package types + +import ( + "time" + + . "github.com/tendermint/go-common" + "github.com/tendermint/go-crypto" + "github.com/tendermint/go-wire" + ptypes "github.com/eris-ltd/eris-db/permission/types" +) + +//------------------------------------------------------------ +// we store the gendoc in the db + +var GenDocKey = []byte("GenDocKey") + +//------------------------------------------------------------ +// core types for a genesis definition + +type BasicAccount struct { + Address []byte `json:"address"` + Amount int64 `json:"amount"` +} + +type GenesisAccount struct { + Address []byte `json:"address"` + Amount int64 `json:"amount"` + Name string `json:"name"` + Permissions *ptypes.AccountPermissions `json:"permissions"` +} + +type GenesisValidator struct { + PubKey crypto.PubKeyEd25519 `json:"pub_key"` + Amount int64 `json:"amount"` + Name string `json:"name"` + UnbondTo []BasicAccount `json:"unbond_to"` +} + +type GenesisParams struct { + GlobalPermissions *ptypes.AccountPermissions `json:"global_permissions"` +} + +type GenesisDoc struct { + GenesisTime time.Time `json:"genesis_time"` + ChainID string `json:"chain_id"` + Params *GenesisParams `json:"params"` + Accounts []GenesisAccount `json:"accounts"` + Validators []GenesisValidator `json:"validators"` +} + +//------------------------------------------------------------ +// Make genesis state from file + +func GenesisDocFromJSON(jsonBlob []byte) (genState *GenesisDoc) { + var err error + wire.ReadJSONPtr(&genState, jsonBlob, &err) + if err != nil { + Exit(Fmt("Couldn't read GenesisDoc: %v", err)) + } + return +} diff --git a/test/filters/filter_test.go b/test/filters/filter_test.go index adfbc98b2918a47670718af17f831ff86b9c199e..ba0905f2d9f1710b82a46d230ac68fec15ca4e1a 100644 --- a/test/filters/filter_test.go +++ b/test/filters/filter_test.go @@ -2,7 +2,7 @@ package filters import ( "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/suite" + "github.com/stretchr/testify/suite" . "github.com/eris-ltd/eris-db/erisdb/pipe" "sync" "testing" diff --git a/test/mock/mock_web_api_test.go b/test/mock/mock_web_api_test.go index 084c85a889522fff16d1265e3d3a3c492cfbb3e7..0d2944b127b9f6407d09c1a3e8bd36ea984fff10 100644 --- a/test/mock/mock_web_api_test.go +++ b/test/mock/mock_web_api_test.go @@ -5,12 +5,12 @@ import ( "bytes" "encoding/hex" // edb "github.com/eris-ltd/erisdb/erisdb" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/suite" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/suite" + "github.com/tendermint/log15" + "github.com/eris-ltd/eris-db/account" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/types" edb "github.com/eris-ltd/eris-db/erisdb" ep "github.com/eris-ltd/eris-db/erisdb/pipe" "github.com/eris-ltd/eris-db/rpc" diff --git a/test/mock/pipe.go b/test/mock/pipe.go index 8408236bab4da78d199eadb66fc251c6961739d3..c8b71556aec9a058cd76e0b9334b18455a999a69 100644 --- a/test/mock/pipe.go +++ b/test/mock/pipe.go @@ -4,9 +4,9 @@ import ( ep "github.com/eris-ltd/eris-db/erisdb/pipe" td "github.com/eris-ltd/eris-db/test/testdata/testdata" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/account" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + "github.com/tendermint/tendermint/types" ) // Base struct. diff --git a/test/server/http_burst_test.go b/test/server/http_burst_test.go index cc415a0e7aefdedbaff975774ca8ab0f88b312e2..2ac5dbcc09a8201c2bde87e2f2114587205408ff 100644 --- a/test/server/http_burst_test.go +++ b/test/server/http_burst_test.go @@ -2,7 +2,7 @@ package server import ( // "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" "net/http" "testing" "time" diff --git a/test/server/scumbag.go b/test/server/scumbag.go index dbf50eff00cb111f2eb1e60fea15286c7e361e01..807206012dc390c919a5c88dd26c64c7abb29d65 100644 --- a/test/server/scumbag.go +++ b/test/server/scumbag.go @@ -2,8 +2,8 @@ package server import ( "encoding/json" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/gin-gonic/gin" + "github.com/tendermint/log15" "github.com/eris-ltd/eris-db/rpc" "github.com/eris-ltd/eris-db/server" "os" diff --git a/test/server/ws_burst_test.go b/test/server/ws_burst_test.go index 129ddb7d1f908a44021aa8caa4a2e001b111a791..3b5749aa245f1010e6fa4e8528be0a60751aad53 100644 --- a/test/server/ws_burst_test.go +++ b/test/server/ws_burst_test.go @@ -1,7 +1,7 @@ package server import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" "github.com/eris-ltd/eris-db/client" "github.com/eris-ltd/eris-db/server" "testing" diff --git a/test/testdata/filters/testdata_filters.go b/test/testdata/filters/testdata_filters.go index 394a16a4e6d773f632cf39addf862c0923aa0392..7f69c6e57a07d02148970c54741e7f76320de090 100644 --- a/test/testdata/filters/testdata_filters.go +++ b/test/testdata/filters/testdata_filters.go @@ -4,8 +4,8 @@ import ( edb "github.com/eris-ltd/eris-db/erisdb" ep "github.com/eris-ltd/eris-db/erisdb/pipe" - stypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + stypes "github.com/eris-ltd/eris-db/state/types" + "github.com/tendermint/tendermint/types" ) var testDataJson = `{ diff --git a/test/testdata/helpers.go b/test/testdata/helpers.go index c45516117701eccafdb7233182538209df2dc2e5..48dff08f80f261a970e6ad647cdd885de7cfb815 100644 --- a/test/testdata/helpers.go +++ b/test/testdata/helpers.go @@ -7,14 +7,14 @@ import ( "os" "path" - . "github.com/tendermint/tendermint/common" - stypes "github.com/tendermint/tendermint/state/types" + . "github.com/tendermint/go-common" + stypes "github.com/eris-ltd/eris-db/state/types" "github.com/tendermint/tendermint/types" - "github.com/tendermint/tendermint/wire" + "github.com/tendermint/go-wire" ) const TendermintConfigDefault = `# This is a TOML config file. -# For more information, see https://github.com/toml-lang/toml +# For more information, see https:/github.com/toml-lang/toml moniker = "__MONIKER__" seeds = "" diff --git a/test/testdata/testdata/testdata.go b/test/testdata/testdata/testdata.go index 2b9ff63c0d9388b064de263fc2c48d6c847ec2e7..01c25f6f033a9952b2e0d4999f891d5ad95483f0 100644 --- a/test/testdata/testdata/testdata.go +++ b/test/testdata/testdata/testdata.go @@ -1,10 +1,10 @@ package testdata import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" - ctypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/rpc/core/types" - stypes "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/eris-ltd/eris-db/account" + ctypes "github.com/tendermint/tendermint/rpc/core/types" + stypes "github.com/eris-ltd/eris-db/state/types" + "github.com/tendermint/tendermint/types" edb "github.com/eris-ltd/eris-db/erisdb" ep "github.com/eris-ltd/eris-db/erisdb/pipe" ) diff --git a/test/transacting/transacting_tes.go b/test/transacting/transacting_tes.go index 4d5717fc0e1f4bb6d8ed7072b2ffb8884990b5db..69777eac77c3733f0e81fc2f347d9c15b1dd070e 100644 --- a/test/transacting/transacting_tes.go +++ b/test/transacting/transacting_tes.go @@ -4,8 +4,8 @@ package transacting import ( "bytes" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/suite" - // "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" + "github.com/stretchr/testify/suite" + // "github.com/tendermint/tendermint/types" edb "github.com/eris-ltd/eris-db/erisdb" ess "github.com/eris-ltd/eris-db/erisdb/erisdbss" // ep "github.com/eris-ltd/eris-db/erisdb/pipe" @@ -17,8 +17,8 @@ import ( "os" "path" "testing" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/gin-gonic/gin" + "github.com/tendermint/log15" "runtime" ) diff --git a/test/web_api/query_test.go b/test/web_api/query_test.go index ae18061502a7608bb5d2fa419f3a6813bbeb76d5..54d2ce48271faaa8fd98432e9ba9151c9c83ebe1 100644 --- a/test/web_api/query_test.go +++ b/test/web_api/query_test.go @@ -4,7 +4,7 @@ package web_api import ( "bytes" "fmt" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/suite" + "github.com/stretchr/testify/suite" edb "github.com/eris-ltd/eris-db/erisdb" ess "github.com/eris-ltd/eris-db/erisdb/erisdbss" ep "github.com/eris-ltd/eris-db/erisdb/pipe" diff --git a/test/web_api/shared.go b/test/web_api/shared.go index 4f08a3c45f73170b113a1cef609d13220fb7a2a0..406fbbcd8ac867c51f4460f10e51410afb038aac 100644 --- a/test/web_api/shared.go +++ b/test/web_api/shared.go @@ -1,8 +1,8 @@ package web_api import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/log15" + "github.com/gin-gonic/gin" + "github.com/tendermint/log15" "os" "runtime" ) diff --git a/test/web_api/web_api_test.go b/test/web_api/web_api_test.go index ede734cee1d8b20d38b33db183e2dd7198ffe20c..c47bb8ceb2ee95fa10d3c97cc8a2059faccecb13 100644 --- a/test/web_api/web_api_test.go +++ b/test/web_api/web_api_test.go @@ -6,9 +6,9 @@ import ( "encoding/hex" "fmt" // edb "github.com/eris-ltd/erisdb/erisdb" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/gin-gonic/gin" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/suite" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/account" + "github.com/gin-gonic/gin" + "github.com/stretchr/testify/suite" + "github.com/eris-ltd/eris-db/account" edb "github.com/eris-ltd/eris-db/erisdb" ess "github.com/eris-ltd/eris-db/erisdb/erisdbss" ep "github.com/eris-ltd/eris-db/erisdb/pipe" diff --git a/tmsp/erisdb.go b/tmsp/erisdb.go index af509616ae83ff749d07a97e289c87ef7d3c682c..9059773cc2aaddd9ec656cce28e1163b3dab4292 100644 --- a/tmsp/erisdb.go +++ b/tmsp/erisdb.go @@ -7,12 +7,13 @@ import ( //sm "github.com/eris-ltd/eris-db/state" // txs "github.com/eris-ltd/eris-db/txs" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/events" - sm "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/state" - txs "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/types" - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/tendermint/tendermint/wire" + sm "github.com/eris-ltd/eris-db/state" + types "github.com/eris-ltd/eris-db/txs" - "github.com/tendermint/tmsp/types" + "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/events" + + tmsp "github.com/tendermint/tmsp/types" ) //-------------------------------------------------------------------------------- @@ -39,7 +40,7 @@ func NewErisDBApp(s *sm.State, evsw *events.EventSwitch) *ErisDBApp { } // Implements tmsp.Application -func (app *ErisDBApp) Open() types.AppContext { +func (app *ErisDBApp) Open() tmsp.AppContext { app.mtx.Lock() state := app.state.Copy() app.mtx.Unlock() @@ -72,36 +73,36 @@ func (appC *ErisDBAppContext) Info() []string { return []string{"ErisDB"} } -func (appC *ErisDBAppContext) SetOption(key string, value string) types.RetCode { +func (appC *ErisDBAppContext) SetOption(key string, value string) tmsp.RetCode { return 0 } -func (appC ErisDBAppContext) AppendTx(txBytes []byte) ([]types.Event, types.RetCode) { - var n int64 +func (appC ErisDBAppContext) AppendTx(txBytes []byte) ([]tmsp.Event, tmsp.RetCode) { + var n int var err error - tx := new(txs.Tx) + tx := new(types.Tx) buf := bytes.NewBuffer(txBytes) - wire.ReadBinaryPtr(tx, buf, &n, &err) + wire.ReadBinaryPtr(tx, buf, len(txBytes), &n, &err) if err != nil { // TODO: handle error - return nil, types.RetCodeEncodingError + return nil, tmsp.RetCodeEncodingError } err = sm.ExecTx(appC.cache, *tx, true, appC.evc) if err != nil { // TODO: handle error - return nil, types.RetCodeInternalError // ?! + return nil, tmsp.RetCodeInternalError // ?! } - return nil, types.RetCodeOK + return nil, tmsp.RetCodeOK } -func (appC *ErisDBAppContext) GetHash() ([]byte, types.RetCode) { +func (appC *ErisDBAppContext) GetHash() ([]byte, tmsp.RetCode) { appC.cache.Sync() - return appC.state.Hash(), types.RetCodeOK + return appC.state.Hash(), tmsp.RetCodeOK } -func (appC *ErisDBAppContext) Commit() types.RetCode { +func (appC *ErisDBAppContext) Commit() tmsp.RetCode { // save state to disk appC.state.Save() @@ -115,7 +116,7 @@ func (appC *ErisDBAppContext) Commit() types.RetCode { return 0 } -func (appC *ErisDBAppContext) Rollback() types.RetCode { +func (appC *ErisDBAppContext) Rollback() tmsp.RetCode { appC.app.mtx.Lock() appC.state = appC.app.state appC.app.mtx.Unlock() @@ -124,11 +125,11 @@ func (appC *ErisDBAppContext) Rollback() types.RetCode { return 0 } -func (appC *ErisDBAppContext) AddListener(key string) types.RetCode { +func (appC *ErisDBAppContext) AddListener(key string) tmsp.RetCode { return 0 } -func (appC *ErisDBAppContext) RemListener(key string) types.RetCode { +func (appC *ErisDBAppContext) RemListener(key string) tmsp.RetCode { return 0 } diff --git a/txs/README.md b/txs/README.md new file mode 100644 index 0000000000000000000000000000000000000000..f99294b007dd8ac4b3a453f0256d9c0aeb43d247 --- /dev/null +++ b/txs/README.md @@ -0,0 +1,61 @@ +# `tendermint/block` + +## Block + +TODO: document + +### Header + +### Validation + +### Data + +## PartSet + +PartSet is used to split a byteslice of data into parts (pieces) for transmission. +By splitting data into smaller parts and computing a Merkle root hash on the list, +you can verify that a part is legitimately part of the complete data, and the +part can be forwarded to other peers before all the parts are known. In short, +it's a fast way to propagate a large file over a gossip network. + +PartSet was inspired by the LibSwift project. + +Usage: + +```Go +data := RandBytes(2 << 20) // Something large + +partSet := NewPartSetFromData(data) +partSet.Total() // Total number of 4KB parts +partSet.Count() // Equal to the Total, since we already have all the parts +partSet.Hash() // The Merkle root hash +partSet.BitArray() // A BitArray of partSet.Total() 1's + +header := partSet.Header() // Send this to the peer +header.Total // Total number of parts +header.Hash // The merkle root hash + +// Now we'll reconstruct the data from the parts +partSet2 := NewPartSetFromHeader(header) +partSet2.Total() // Same total as partSet.Total() +partSet2.Count() // Zero, since this PartSet doesn't have any parts yet. +partSet2.Hash() // Same hash as in partSet.Hash() +partSet2.BitArray() // A BitArray of partSet.Total() 0's + +// In a gossip network the parts would arrive in arbitrary order, perhaps +// in response to explicit requests for parts, or optimistically in response +// to the receiving peer's partSet.BitArray(). +for !partSet2.IsComplete() { + part := receivePartFromGossipNetwork() + added, err := partSet2.AddPart(part) + if err != nil { + // A wrong part, + // the merkle trail does not hash to partSet2.Hash() + } else if !added { + // A duplicate part already received + } +} + +data2, _ := ioutil.ReadAll(partSet2.GetReader()) +bytes.Equal(data, data2) // true +``` diff --git a/txs/config.go b/txs/config.go new file mode 100644 index 0000000000000000000000000000000000000000..cb982879786196ca20c6e3c6eab16b1b1ecb76e9 --- /dev/null +++ b/txs/config.go @@ -0,0 +1,13 @@ +package types + +import ( + cfg "github.com/tendermint/go-config" +) + +var config cfg.Config = nil + +func init() { + cfg.OnConfig(func(newConfig cfg.Config) { + config = newConfig + }) +} diff --git a/txs/events.go b/txs/events.go new file mode 100644 index 0000000000000000000000000000000000000000..edf7046c4b5e4ba7b54550206a0056b10c0082a2 --- /dev/null +++ b/txs/events.go @@ -0,0 +1,133 @@ +package types + +import ( + "fmt" + "time" + + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" + + "github.com/tendermint/tendermint/types" // Block +) + +// Functions to generate eventId strings + +func EventStringAccInput(addr []byte) string { return fmt.Sprintf("Acc/%X/Input", addr) } +func EventStringAccOutput(addr []byte) string { return fmt.Sprintf("Acc/%X/Output", addr) } +func EventStringAccCall(addr []byte) string { return fmt.Sprintf("Acc/%X/Call", addr) } +func EventStringLogEvent(addr []byte) string { return fmt.Sprintf("Log/%X", addr) } +func EventStringPermissions(name string) string { return fmt.Sprintf("Permissions/%s", name) } +func EventStringNameReg(name string) string { return fmt.Sprintf("NameReg/%s", name) } +func EventStringBond() string { return "Bond" } +func EventStringUnbond() string { return "Unbond" } +func EventStringRebond() string { return "Rebond" } +func EventStringDupeout() string { return "Dupeout" } +func EventStringNewBlock() string { return "NewBlock" } +func EventStringFork() string { return "Fork" } + +func EventStringNewRound() string { return fmt.Sprintf("NewRound") } +func EventStringTimeoutPropose() string { return fmt.Sprintf("TimeoutPropose") } +func EventStringCompleteProposal() string { return fmt.Sprintf("CompleteProposal") } +func EventStringPolka() string { return fmt.Sprintf("Polka") } +func EventStringUnlock() string { return fmt.Sprintf("Unlock") } +func EventStringLock() string { return fmt.Sprintf("Lock") } +func EventStringRelock() string { return fmt.Sprintf("Relock") } +func EventStringTimeoutWait() string { return fmt.Sprintf("TimeoutWait") } +func EventStringVote() string { return fmt.Sprintf("Vote") } + +//---------------------------------------- + +const ( + EventDataTypeNewBlock = byte(0x01) + EventDataTypeFork = byte(0x02) + EventDataTypeTx = byte(0x03) + EventDataTypeCall = byte(0x04) + EventDataTypeLog = byte(0x05) + + EventDataTypeRoundState = byte(0x11) + EventDataTypeVote = byte(0x12) +) + +type EventData interface { + AssertIsEventData() +} + +var _ = wire.RegisterInterface( + struct{ EventData }{}, + wire.ConcreteType{EventDataNewBlock{}, EventDataTypeNewBlock}, + // wire.ConcreteType{EventDataFork{}, EventDataTypeFork }, + wire.ConcreteType{EventDataTx{}, EventDataTypeTx}, + wire.ConcreteType{EventDataCall{}, EventDataTypeCall}, + wire.ConcreteType{EventDataLog{}, EventDataTypeLog}, + wire.ConcreteType{EventDataRoundState{}, EventDataTypeRoundState}, + wire.ConcreteType{EventDataVote{}, EventDataTypeVote}, +) + +// Most event messages are basic types (a block, a transaction) +// but some (an input to a call tx or a receive) are more exotic + +type EventDataNewBlock struct { + Block *types.Block `json:"block"` +} + +// All txs fire EventDataTx, but only CallTx might have Return or Exception +type EventDataTx struct { + Tx Tx `json:"tx"` + Return []byte `json:"return"` + Exception string `json:"exception"` +} + +// EventDataCall fires when we call a contract, and when a contract calls another contract +type EventDataCall struct { + CallData *CallData `json:"call_data"` + Origin []byte `json:"origin"` + TxID []byte `json:"tx_id"` + Return []byte `json:"return"` + Exception string `json:"exception"` +} + +type CallData struct { + Caller []byte `json:"caller"` + Callee []byte `json:"callee"` + Data []byte `json:"data"` + Value int64 `json:"value"` + Gas int64 `json:"gas"` +} + +// EventDataLog fires when a contract executes the LOG opcode +type EventDataLog struct { + Address Word256 `json:"address"` + Topics []Word256 `json:"topics"` + Data []byte `json:"data"` + Height int64 `json:"height"` +} + +// We fire the most recent round state that led to the event +// (ie. NewRound will have the previous rounds state) +type EventDataRoundState struct { + CurrentTime time.Time `json:"current_time"` + + Height int `json:"height"` + Round int `json:"round"` + Step string `json:"step"` + StartTime time.Time `json:"start_time"` + CommitTime time.Time `json:"commit_time"` + Proposal *types.Proposal `json:"proposal"` + ProposalBlock *types.Block `json:"proposal_block"` + LockedRound int `json:"locked_round"` + LockedBlock *types.Block `json:"locked_block"` + POLRound int `json:"pol_round"` +} + +type EventDataVote struct { + Index int + Address []byte + Vote *types.Vote +} + +func (_ EventDataNewBlock) AssertIsEventData() {} +func (_ EventDataTx) AssertIsEventData() {} +func (_ EventDataCall) AssertIsEventData() {} +func (_ EventDataLog) AssertIsEventData() {} +func (_ EventDataRoundState) AssertIsEventData() {} +func (_ EventDataVote) AssertIsEventData() {} diff --git a/txs/log.go b/txs/log.go new file mode 100644 index 0000000000000000000000000000000000000000..dbe8a67821e8d2603e19e7ee716b2c61d80b0309 --- /dev/null +++ b/txs/log.go @@ -0,0 +1,7 @@ +package types + +import ( + "github.com/tendermint/go-logger" +) + +var log = logger.New("module", "types") diff --git a/txs/names.go b/txs/names.go new file mode 100644 index 0000000000000000000000000000000000000000..2f4c8ff83377289626b8b4414bc96946274ec3ae --- /dev/null +++ b/txs/names.go @@ -0,0 +1,55 @@ +package types + +import ( + "regexp" +) + +var ( + MinNameRegistrationPeriod int = 5 + + // NOTE: base costs and validity checks are here so clients + // can use them without importing state + + // cost for storing a name for a block is + // CostPerBlock*CostPerByte*(len(data) + 32) + NameByteCostMultiplier int64 = 1 + NameBlockCostMultiplier int64 = 1 + + MaxNameLength = 64 + MaxDataLength = 1 << 16 + + // Name should be file system lik + // Data should be anything permitted in JSON + regexpAlphaNum = regexp.MustCompile("^[a-zA-Z0-9._/-@]*$") + regexpJSON = regexp.MustCompile(`^[a-zA-Z0-9_/ \-+"':,\n\t.{}()\[\]]*$`) +) + +// filter strings +func validateNameRegEntryName(name string) bool { + return regexpAlphaNum.Match([]byte(name)) +} + +func validateNameRegEntryData(data string) bool { + return regexpJSON.Match([]byte(data)) +} + +// base cost is "effective" number of bytes +func NameBaseCost(name, data string) int64 { + return int64(len(data) + 32) +} + +func NameCostPerBlock(baseCost int64) int64 { + return NameBlockCostMultiplier * NameByteCostMultiplier * baseCost +} + +type NameRegEntry struct { + Name string `json:"name"` // registered name for the entry + Owner []byte `json:"owner"` // address that created the entry + Data string `json:"data"` // data to store under this name + Expires int `json:"expires"` // block at which this entry expires +} + +func (entry *NameRegEntry) Copy() *NameRegEntry { + entryCopy := *entry + return &entryCopy +} diff --git a/txs/tx.go b/txs/tx.go new file mode 100644 index 0000000000000000000000000000000000000000..e39dd447dc648d64dcd3b66377839caef5fd9117 --- /dev/null +++ b/txs/tx.go @@ -0,0 +1,377 @@ +package types + +import ( + "encoding/json" + "errors" + "io" + + "golang.org/x/crypto/ripemd160" + + . "github.com/tendermint/go-common" + "github.com/tendermint/go-wire" + acm "github.com/eris-ltd/eris-db/account" + ptypes "github.com/eris-ltd/eris-db/permission/types" + + "github.com/tendermint/tendermint/types" // votes for dupeout .. +) + +var ( + ErrTxInvalidAddress = errors.New("Error invalid address") + ErrTxDuplicateAddress = errors.New("Error duplicate address") + ErrTxInvalidAmount = errors.New("Error invalid amount") + ErrTxInsufficientFunds = errors.New("Error insufficient funds") + ErrTxInsufficientGasPrice = errors.New("Error insufficient gas price") + ErrTxUnknownPubKey = errors.New("Error unknown pubkey") + ErrTxInvalidPubKey = errors.New("Error invalid pubkey") + ErrTxInvalidSignature = errors.New("Error invalid signature") + ErrTxPermissionDenied = errors.New("Error permission denied") +) + +type ErrTxInvalidString struct { + Msg string +} + +func (e ErrTxInvalidString) Error() string { + return e.Msg +} + +type ErrTxInvalidSequence struct { + Got int + Expected int +} + +func (e ErrTxInvalidSequence) Error() string { + return Fmt("Error invalid sequence. Got %d, expected %d", e.Got, e.Expected) +} + +/* +Tx (Transaction) is an atomic operation on the ledger state. + +Account Txs: + - SendTx Send coins to address + - CallTx Send a msg to a contract that runs in the vm + - NameTx Store some value under a name in the global namereg + +Validation Txs: + - BondTx New validator posts a bond + - UnbondTx Validator leaves + - DupeoutTx Validator dupes out (equivocates) + +Admin Txs: + - PermissionsTx +*/ + +type Tx interface { + WriteSignBytes(chainID string, w io.Writer, n *int, err *error) +} + +// Types of Tx implementations +const ( + // Account transactions + TxTypeSend = byte(0x01) + TxTypeCall = byte(0x02) + TxTypeName = byte(0x03) + + // Validation transactions + TxTypeBond = byte(0x11) + TxTypeUnbond = byte(0x12) + TxTypeRebond = byte(0x13) + TxTypeDupeout = byte(0x14) + + // Admin transactions + TxTypePermissions = byte(0x20) +) + +// for wire.readReflect +var _ = wire.RegisterInterface( + struct{ Tx }{}, + wire.ConcreteType{&SendTx{}, TxTypeSend}, + wire.ConcreteType{&CallTx{}, TxTypeCall}, + wire.ConcreteType{&NameTx{}, TxTypeName}, + wire.ConcreteType{&BondTx{}, TxTypeBond}, + wire.ConcreteType{&UnbondTx{}, TxTypeUnbond}, + wire.ConcreteType{&RebondTx{}, TxTypeRebond}, + wire.ConcreteType{&DupeoutTx{}, TxTypeDupeout}, + wire.ConcreteType{&PermissionsTx{}, TxTypePermissions}, +) + +//----------------------------------------------------------------------------- + +type TxInput struct { + Address []byte `json:"address"` // Hash of the PubKey + Amount int64 `json:"amount"` // Must not exceed account balance + Sequence int `json:"sequence"` // Must be 1 greater than the last committed TxInput + Signature acm.Signature `json:"signature"` // Depends on the PubKey type and the whole Tx + PubKey acm.PubKey `json:"pub_key"` // Must not be nil, may be nil +} + +func (txIn *TxInput) ValidateBasic() error { + if len(txIn.Address) != 20 { + return ErrTxInvalidAddress + } + if txIn.Amount == 0 { + return ErrTxInvalidAmount + } + return nil +} + +func (txIn *TxInput) WriteSignBytes(w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"address":"%X","amount":%v,"sequence":%v}`, txIn.Address, txIn.Amount, txIn.Sequence)), w, n, err) +} + +func (txIn *TxInput) String() string { + return Fmt("TxInput{%X,%v,%v,%v,%v}", txIn.Address, txIn.Amount, txIn.Sequence, txIn.Signature, txIn.PubKey) +} + +//----------------------------------------------------------------------------- + +type TxOutput struct { + Address []byte `json:"address"` // Hash of the PubKey + Amount int64 `json:"amount"` // The sum of all outputs must not exceed the inputs. +} + +func (txOut *TxOutput) ValidateBasic() error { + if len(txOut.Address) != 20 { + return ErrTxInvalidAddress + } + if txOut.Amount == 0 { + return ErrTxInvalidAmount + } + return nil +} + +func (txOut *TxOutput) WriteSignBytes(w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"address":"%X","amount":%v}`, txOut.Address, txOut.Amount)), w, n, err) +} + +func (txOut *TxOutput) String() string { + return Fmt("TxOutput{%X,%v}", txOut.Address, txOut.Amount) +} + +//----------------------------------------------------------------------------- + +type SendTx struct { + Inputs []*TxInput `json:"inputs"` + Outputs []*TxOutput `json:"outputs"` +} + +func (tx *SendTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"chain_id":%s`, jsonEscape(chainID))), w, n, err) + wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeSend)), w, n, err) + for i, in := range tx.Inputs { + in.WriteSignBytes(w, n, err) + if i != len(tx.Inputs)-1 { + wire.WriteTo([]byte(","), w, n, err) + } + } + wire.WriteTo([]byte(`],"outputs":[`), w, n, err) + for i, out := range tx.Outputs { + out.WriteSignBytes(w, n, err) + if i != len(tx.Outputs)-1 { + wire.WriteTo([]byte(","), w, n, err) + } + } + wire.WriteTo([]byte(`]}]}`), w, n, err) +} + +func (tx *SendTx) String() string { + return Fmt("SendTx{%v -> %v}", tx.Inputs, tx.Outputs) +} + +//----------------------------------------------------------------------------- + +type CallTx struct { + Input *TxInput `json:"input"` + Address []byte `json:"address"` + GasLimit int64 `json:"gas_limit"` + Fee int64 `json:"fee"` + Data []byte `json:"data"` +} + +func (tx *CallTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"chain_id":%s`, jsonEscape(chainID))), w, n, err) + wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","data":"%X"`, TxTypeCall, tx.Address, tx.Data)), w, n, err) + wire.WriteTo([]byte(Fmt(`,"fee":%v,"gas_limit":%v,"input":`, tx.Fee, tx.GasLimit)), w, n, err) + tx.Input.WriteSignBytes(w, n, err) + wire.WriteTo([]byte(`}]}`), w, n, err) +} + +func (tx *CallTx) String() string { + return Fmt("CallTx{%v -> %x: %x}", tx.Input, tx.Address, tx.Data) +} + +func NewContractAddress(caller []byte, nonce int) []byte { + temp := make([]byte, 32+8) + copy(temp, caller) + PutInt64BE(temp[32:], int64(nonce)) + hasher := ripemd160.New() + hasher.Write(temp) // does not error + return hasher.Sum(nil) +} + +//----------------------------------------------------------------------------- + +type NameTx struct { + Input *TxInput `json:"input"` + Name string `json:"name"` + Data string `json:"data"` + Fee int64 `json:"fee"` +} + +func (tx *NameTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"chain_id":%s`, jsonEscape(chainID))), w, n, err) + wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"data":%s,"fee":%v`, TxTypeName, jsonEscape(tx.Data), tx.Fee)), w, n, err) + wire.WriteTo([]byte(`,"input":`), w, n, err) + tx.Input.WriteSignBytes(w, n, err) + wire.WriteTo([]byte(Fmt(`,"name":%s`, jsonEscape(tx.Name))), w, n, err) + wire.WriteTo([]byte(`}]}`), w, n, err) +} + +func (tx *NameTx) ValidateStrings() error { + if len(tx.Name) == 0 { + return ErrTxInvalidString{"Name must not be empty"} + } + if len(tx.Name) > MaxNameLength { + return ErrTxInvalidString{Fmt("Name is too long. Max %d bytes", MaxNameLength)} + } + if len(tx.Data) > MaxDataLength { + return ErrTxInvalidString{Fmt("Data is too long. Max %d bytes", MaxDataLength)} + } + + if !validateNameRegEntryName(tx.Name) { + return ErrTxInvalidString{Fmt("Invalid characters found in NameTx.Name (%s). Only alphanumeric, underscores, dashes, forward slashes, and @ are allowed", tx.Name)} + } + + if !validateNameRegEntryData(tx.Data) { + return ErrTxInvalidString{Fmt("Invalid characters found in NameTx.Data (%s). Only the kind of things found in a JSON file are allowed", tx.Data)} + } + + return nil +} + +func (tx *NameTx) String() string { + return Fmt("NameTx{%v -> %s: %s}", tx.Input, tx.Name, tx.Data) +} + +//----------------------------------------------------------------------------- + +type BondTx struct { + PubKey acm.PubKeyEd25519 `json:"pub_key"` + Signature acm.SignatureEd25519 `json:"signature"` + Inputs []*TxInput `json:"inputs"` + UnbondTo []*TxOutput `json:"unbond_to"` +} + +func (tx *BondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"chain_id":%s`, jsonEscape(chainID))), w, n, err) + wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"inputs":[`, TxTypeBond)), w, n, err) + for i, in := range tx.Inputs { + in.WriteSignBytes(w, n, err) + if i != len(tx.Inputs)-1 { + wire.WriteTo([]byte(","), w, n, err) + } + } + wire.WriteTo([]byte(Fmt(`],"pub_key":`)), w, n, err) + wire.WriteTo(wire.JSONBytes(tx.PubKey), w, n, err) + wire.WriteTo([]byte(`,"unbond_to":[`), w, n, err) + for i, out := range tx.UnbondTo { + out.WriteSignBytes(w, n, err) + if i != len(tx.UnbondTo)-1 { + wire.WriteTo([]byte(","), w, n, err) + } + } + wire.WriteTo([]byte(`]}]}`), w, n, err) +} + +func (tx *BondTx) String() string { + return Fmt("BondTx{%v: %v -> %v}", tx.PubKey, tx.Inputs, tx.UnbondTo) +} + +//----------------------------------------------------------------------------- + +type UnbondTx struct { + Address []byte `json:"address"` + Height int `json:"height"` + Signature acm.SignatureEd25519 `json:"signature"` +} + +func (tx *UnbondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"chain_id":%s`, jsonEscape(chainID))), w, n, err) + wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeUnbond, tx.Address, tx.Height)), w, n, err) +} + +func (tx *UnbondTx) String() string { + return Fmt("UnbondTx{%X,%v,%v}", tx.Address, tx.Height, tx.Signature) +} + +//----------------------------------------------------------------------------- + +type RebondTx struct { + Address []byte `json:"address"` + Height int `json:"height"` + Signature acm.SignatureEd25519 `json:"signature"` +} + +func (tx *RebondTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"chain_id":%s`, jsonEscape(chainID))), w, n, err) + wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"address":"%X","height":%v}]}`, TxTypeRebond, tx.Address, tx.Height)), w, n, err) +} + +func (tx *RebondTx) String() string { + return Fmt("RebondTx{%X,%v,%v}", tx.Address, tx.Height, tx.Signature) +} + +//----------------------------------------------------------------------------- + +type DupeoutTx struct { + Address []byte `json:"address"` + VoteA types.Vote `json:"vote_a"` + VoteB types.Vote `json:"vote_b"` +} + +func (tx *DupeoutTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + PanicSanity("DupeoutTx has no sign bytes") +} + +func (tx *DupeoutTx) String() string { + return Fmt("DupeoutTx{%X,%v,%v}", tx.Address, tx.VoteA, tx.VoteB) +} + +//----------------------------------------------------------------------------- + +type PermissionsTx struct { + Input *TxInput `json:"input"` + PermArgs ptypes.PermArgs `json:"args"` +} + +func (tx *PermissionsTx) WriteSignBytes(chainID string, w io.Writer, n *int, err *error) { + wire.WriteTo([]byte(Fmt(`{"chain_id":%s`, jsonEscape(chainID))), w, n, err) + wire.WriteTo([]byte(Fmt(`,"tx":[%v,{"args":"`, TxTypePermissions)), w, n, err) + wire.WriteJSON(tx.PermArgs, w, n, err) + wire.WriteTo([]byte(`","input":`), w, n, err) + tx.Input.WriteSignBytes(w, n, err) + wire.WriteTo([]byte(`}]}`), w, n, err) +} + +func (tx *PermissionsTx) String() string { + return Fmt("PermissionsTx{%v -> %v}", tx.Input, tx.PermArgs) +} + +//----------------------------------------------------------------------------- + +// This should match the leaf hashes of Block.Data.Hash()'s SimpleMerkleTree. +func TxID(chainID string, tx Tx) []byte { + signBytes := acm.SignBytes(chainID, tx) + return wire.BinaryRipemd160(signBytes) +} + +//-------------------------------------------------------------------------------- + +// Contract: This function is deterministic and completely reversible. +func jsonEscape(str string) string { + escapedBytes, err := json.Marshal(str) + if err != nil { + PanicSanity(Fmt("Error json-escaping a string", str)) + } + return string(escapedBytes) +} diff --git a/txs/tx_test.go b/txs/tx_test.go new file mode 100644 index 0000000000000000000000000000000000000000..8e772b9ac7fef275e561924c658d50b49ee16917 --- /dev/null +++ b/txs/tx_test.go @@ -0,0 +1,178 @@ +package types + +import ( + "testing" + + . "github.com/tendermint/go-common" + _ "github.com/tendermint/tendermint/config/tendermint_test" + acm "github.com/eris-ltd/eris-db/account" + ptypes "github.com/eris-ltd/eris-db/permission/types" +) + +var chainID string + +func init() { + chainID = config.GetString("chain_id") +} + +func TestSendTxSignable(t *testing.T) { + sendTx := &SendTx{ + Inputs: []*TxInput{ + &TxInput{ + Address: []byte("input1"), + Amount: 12345, + Sequence: 67890, + }, + &TxInput{ + Address: []byte("input2"), + Amount: 111, + Sequence: 222, + }, + }, + Outputs: []*TxOutput{ + &TxOutput{ + Address: []byte("output1"), + Amount: 333, + }, + &TxOutput{ + Address: []byte("output2"), + Amount: 444, + }, + }, + } + signBytes := acm.SignBytes(chainID, sendTx) + signStr := string(signBytes) + expected := Fmt(`{"chain_id":"%s","tx":[1,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"outputs":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`, + config.GetString("chain_id")) + if signStr != expected { + t.Errorf("Got unexpected sign string for SendTx. Expected:\n%v\nGot:\n%v", expected, signStr) + } +} + +func TestCallTxSignable(t *testing.T) { + callTx := &CallTx{ + Input: &TxInput{ + Address: []byte("input1"), + Amount: 12345, + Sequence: 67890, + }, + Address: []byte("contract1"), + GasLimit: 111, + Fee: 222, + Data: []byte("data1"), + } + signBytes := acm.SignBytes(chainID, callTx) + signStr := string(signBytes) + expected := Fmt(`{"chain_id":"%s","tx":[2,{"address":"636F6E747261637431","data":"6461746131","fee":222,"gas_limit":111,"input":{"address":"696E70757431","amount":12345,"sequence":67890}}]}`, + config.GetString("chain_id")) + if signStr != expected { + t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr) + } +} + +func TestNameTxSignable(t *testing.T) { + nameTx := &NameTx{ + Input: &TxInput{ + Address: []byte("input1"), + Amount: 12345, + Sequence: 250, + }, + Name: "google.com", + Data: "secretly.not.google.com", + Fee: 1000, + } + signBytes := acm.SignBytes(chainID, nameTx) + signStr := string(signBytes) + expected := Fmt(`{"chain_id":"%s","tx":[3,{"data":"secretly.not.google.com","fee":1000,"input":{"address":"696E70757431","amount":12345,"sequence":250},"name":"google.com"}]}`, + config.GetString("chain_id")) + if signStr != expected { + t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr) + } +} + +func TestBondTxSignable(t *testing.T) { + privKeyBytes := make([]byte, 64) + privAccount := acm.GenPrivAccountFromPrivKeyBytes(privKeyBytes) + bondTx := &BondTx{ + PubKey: privAccount.PubKey.(acm.PubKeyEd25519), + Inputs: []*TxInput{ + &TxInput{ + Address: []byte("input1"), + Amount: 12345, + Sequence: 67890, + }, + &TxInput{ + Address: []byte("input2"), + Amount: 111, + Sequence: 222, + }, + }, + UnbondTo: []*TxOutput{ + &TxOutput{ + Address: []byte("output1"), + Amount: 333, + }, + &TxOutput{ + Address: []byte("output2"), + Amount: 444, + }, + }, + } + signBytes := acm.SignBytes(chainID, bondTx) + signStr := string(signBytes) + expected := Fmt(`{"chain_id":"%s","tx":[17,{"inputs":[{"address":"696E70757431","amount":12345,"sequence":67890},{"address":"696E70757432","amount":111,"sequence":222}],"pub_key":[1,"3B6A27BCCEB6A42D62A3A8D02A6F0D73653215771DE243A63AC048A18B59DA29"],"unbond_to":[{"address":"6F757470757431","amount":333},{"address":"6F757470757432","amount":444}]}]}`, + config.GetString("chain_id")) + if signStr != expected { + t.Errorf("Unexpected sign string for BondTx. \nGot %s\nExpected %s", signStr, expected) + } +} + +func TestUnbondTxSignable(t *testing.T) { + unbondTx := &UnbondTx{ + Address: []byte("address1"), + Height: 111, + } + signBytes := acm.SignBytes(chainID, unbondTx) + signStr := string(signBytes) + expected := Fmt(`{"chain_id":"%s","tx":[18,{"address":"6164647265737331","height":111}]}`, + config.GetString("chain_id")) + if signStr != expected { + t.Errorf("Got unexpected sign string for UnbondTx") + } +} + +func TestRebondTxSignable(t *testing.T) { + rebondTx := &RebondTx{ + Address: []byte("address1"), + Height: 111, + } + signBytes := acm.SignBytes(chainID, rebondTx) + signStr := string(signBytes) + expected := Fmt(`{"chain_id":"%s","tx":[19,{"address":"6164647265737331","height":111}]}`, + config.GetString("chain_id")) + if signStr != expected { + t.Errorf("Got unexpected sign string for RebondTx") + } +} + +func TestPermissionsTxSignable(t *testing.T) { + permsTx := &PermissionsTx{ + Input: &TxInput{ + Address: []byte("input1"), + Amount: 12345, + Sequence: 250, + }, + PermArgs: &ptypes.SetBaseArgs{ + Address: []byte("address1"), + Permission: 1, + Value: true, + }, + } + signBytes := acm.SignBytes(chainID, permsTx) + signStr := string(signBytes) + expected := Fmt(`{"chain_id":"%s","tx":[32,{"args":"[2,{"address":"6164647265737331","permission":1,"value":true}]","input":{"address":"696E70757431","amount":12345,"sequence":250}}]}`, + config.GetString("chain_id")) + if signStr != expected { + t.Errorf("Got unexpected sign string for CallTx. Expected:\n%v\nGot:\n%v", expected, signStr) + } +} diff --git a/txs/tx_utils.go b/txs/tx_utils.go new file mode 100644 index 0000000000000000000000000000000000000000..97bc8a6b8742a28d2bde33badc1e8432b34d7e90 --- /dev/null +++ b/txs/tx_utils.go @@ -0,0 +1,260 @@ +package types + +import ( + "fmt" + acm "github.com/eris-ltd/eris-db/account" + ptypes "github.com/eris-ltd/eris-db/permission/types" +) + +type AccountGetter interface { + GetAccount(addr []byte) *acm.Account +} + +//---------------------------------------------------------------------------- +// SendTx interface for adding inputs/outputs and adding signatures + +func NewSendTx() *SendTx { + return &SendTx{ + Inputs: []*TxInput{}, + Outputs: []*TxOutput{}, + } +} + +func (tx *SendTx) AddInput(st AccountGetter, pubkey acm.PubKey, amt int64) error { + addr := pubkey.Address() + acc := st.GetAccount(addr) + if acc == nil { + return fmt.Errorf("Invalid address %X from pubkey %X", addr, pubkey) + } + return tx.AddInputWithNonce(pubkey, amt, acc.Sequence+1) +} + +func (tx *SendTx) AddInputWithNonce(pubkey acm.PubKey, amt int64, nonce int) error { + addr := pubkey.Address() + tx.Inputs = append(tx.Inputs, &TxInput{ + Address: addr, + Amount: amt, + Sequence: nonce, + Signature: acm.SignatureEd25519{}, + PubKey: pubkey, + }) + return nil +} + +func (tx *SendTx) AddOutput(addr []byte, amt int64) error { + tx.Outputs = append(tx.Outputs, &TxOutput{ + Address: addr, + Amount: amt, + }) + return nil +} + +func (tx *SendTx) SignInput(chainID string, i int, privAccount *acm.PrivAccount) error { + if i >= len(tx.Inputs) { + return fmt.Errorf("Index %v is greater than number of inputs (%v)", i, len(tx.Inputs)) + } + tx.Inputs[i].PubKey = privAccount.PubKey + tx.Inputs[i].Signature = privAccount.Sign(chainID, tx) + return nil +} + +//---------------------------------------------------------------------------- +// CallTx interface for creating tx + +func NewCallTx(st AccountGetter, from acm.PubKey, to, data []byte, amt, gasLimit, fee int64) (*CallTx, error) { + addr := from.Address() + acc := st.GetAccount(addr) + if acc == nil { + return nil, fmt.Errorf("Invalid address %X from pubkey %X", addr, from) + } + + nonce := acc.Sequence + 1 + return NewCallTxWithNonce(from, to, data, amt, gasLimit, fee, nonce), nil +} + +func NewCallTxWithNonce(from acm.PubKey, to, data []byte, amt, gasLimit, fee int64, nonce int) *CallTx { + addr := from.Address() + input := &TxInput{ + Address: addr, + Amount: amt, + Sequence: nonce, + Signature: acm.SignatureEd25519{}, + PubKey: from, + } + + return &CallTx{ + Input: input, + Address: to, + GasLimit: gasLimit, + Fee: fee, + Data: data, + } +} + +func (tx *CallTx) Sign(chainID string, privAccount *acm.PrivAccount) { + tx.Input.PubKey = privAccount.PubKey + tx.Input.Signature = privAccount.Sign(chainID, tx) +} + +//---------------------------------------------------------------------------- +// NameTx interface for creating tx + +func NewNameTx(st AccountGetter, from acm.PubKey, name, data string, amt, fee int64) (*NameTx, error) { + addr := from.Address() + acc := st.GetAccount(addr) + if acc == nil { + return nil, fmt.Errorf("Invalid address %X from pubkey %X", addr, from) + } + + nonce := acc.Sequence + 1 + return NewNameTxWithNonce(from, name, data, amt, fee, nonce), nil +} + +func NewNameTxWithNonce(from acm.PubKey, name, data string, amt, fee int64, nonce int) *NameTx { + addr := from.Address() + input := &TxInput{ + Address: addr, + Amount: amt, + Sequence: nonce, + Signature: acm.SignatureEd25519{}, + PubKey: from, + } + + return &NameTx{ + Input: input, + Name: name, + Data: data, + Fee: fee, + } +} + +func (tx *NameTx) Sign(chainID string, privAccount *acm.PrivAccount) { + tx.Input.PubKey = privAccount.PubKey + tx.Input.Signature = privAccount.Sign(chainID, tx) +} + +//---------------------------------------------------------------------------- +// BondTx interface for adding inputs/outputs and adding signatures + +func NewBondTx(pubkey acm.PubKey) (*BondTx, error) { + pubkeyEd, ok := pubkey.(acm.PubKeyEd25519) + if !ok { + return nil, fmt.Errorf("Pubkey must be ed25519") + } + return &BondTx{ + PubKey: pubkeyEd, + Inputs: []*TxInput{}, + UnbondTo: []*TxOutput{}, + }, nil +} + +func (tx *BondTx) AddInput(st AccountGetter, pubkey acm.PubKey, amt int64) error { + addr := pubkey.Address() + acc := st.GetAccount(addr) + if acc == nil { + return fmt.Errorf("Invalid address %X from pubkey %X", addr, pubkey) + } + return tx.AddInputWithNonce(pubkey, amt, acc.Sequence+1) +} + +func (tx *BondTx) AddInputWithNonce(pubkey acm.PubKey, amt int64, nonce int) error { + addr := pubkey.Address() + tx.Inputs = append(tx.Inputs, &TxInput{ + Address: addr, + Amount: amt, + Sequence: nonce, + Signature: acm.SignatureEd25519{}, + PubKey: pubkey, + }) + return nil +} + +func (tx *BondTx) AddOutput(addr []byte, amt int64) error { + tx.UnbondTo = append(tx.UnbondTo, &TxOutput{ + Address: addr, + Amount: amt, + }) + return nil +} + +func (tx *BondTx) SignBond(chainID string, privAccount *acm.PrivAccount) error { + sig := privAccount.Sign(chainID, tx) + sigEd, ok := sig.(acm.SignatureEd25519) + if !ok { + return fmt.Errorf("Bond signer must be ED25519") + } + tx.Signature = sigEd + return nil +} + +func (tx *BondTx) SignInput(chainID string, i int, privAccount *acm.PrivAccount) error { + if i >= len(tx.Inputs) { + return fmt.Errorf("Index %v is greater than number of inputs (%v)", i, len(tx.Inputs)) + } + tx.Inputs[i].PubKey = privAccount.PubKey + tx.Inputs[i].Signature = privAccount.Sign(chainID, tx) + return nil +} + +//---------------------------------------------------------------------- +// UnbondTx interface for creating tx + +func NewUnbondTx(addr []byte, height int) *UnbondTx { + return &UnbondTx{ + Address: addr, + Height: height, + } +} + +func (tx *UnbondTx) Sign(chainID string, privAccount *acm.PrivAccount) { + tx.Signature = privAccount.Sign(chainID, tx).(acm.SignatureEd25519) +} + +//---------------------------------------------------------------------- +// RebondTx interface for creating tx + +func NewRebondTx(addr []byte, height int) *RebondTx { + return &RebondTx{ + Address: addr, + Height: height, + } +} + +func (tx *RebondTx) Sign(chainID string, privAccount *acm.PrivAccount) { + tx.Signature = privAccount.Sign(chainID, tx).(acm.SignatureEd25519) +} + +//---------------------------------------------------------------------------- +// PermissionsTx interface for creating tx + +func NewPermissionsTx(st AccountGetter, from acm.PubKey, args ptypes.PermArgs) (*PermissionsTx, error) { + addr := from.Address() + acc := st.GetAccount(addr) + if acc == nil { + return nil, fmt.Errorf("Invalid address %X from pubkey %X", addr, from) + } + + nonce := acc.Sequence + 1 + return NewPermissionsTxWithNonce(from, args, nonce), nil +} + +func NewPermissionsTxWithNonce(from acm.PubKey, args ptypes.PermArgs, nonce int) *PermissionsTx { + addr := from.Address() + input := &TxInput{ + Address: addr, + Amount: 1, // NOTE: amounts can't be 0 ... + Sequence: nonce, + Signature: acm.SignatureEd25519{}, + PubKey: from, + } + + return &PermissionsTx{ + Input: input, + PermArgs: args, + } +} + +func (tx *PermissionsTx) Sign(chainID string, privAccount *acm.PrivAccount) { + tx.Input.PubKey = privAccount.PubKey + tx.Input.Signature = privAccount.Sign(chainID, tx) +} diff --git a/util/util_test.go b/util/util_test.go index 69046d219592a4d071331a09855db0c998003e56..deef5ebb81a9af2c5fe4074d10662ebab3bdb145 100644 --- a/util/util_test.go +++ b/util/util_test.go @@ -1,7 +1,7 @@ package util import ( - "github.com/eris-ltd/eris-db/Godeps/_workspace/src/github.com/stretchr/testify/assert" + "github.com/stretchr/testify/assert" "testing" )