diff --git a/go.mod b/go.mod index 1ac310b9..7c969eac 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/improbable-eng/grpc-web v0.15.0 github.com/logrusorgru/aurora v2.0.3+incompatible github.com/onflow/cadence v0.42.1 - github.com/onflow/flow-archive v1.3.4-0.20230503192214-9e81e82d4dcc + github.com/onflow/flow-archive v0.31.14 github.com/onflow/flow-go v0.32.3 github.com/onflow/flow-go-sdk v0.41.12 github.com/onflow/flow-go/crypto v0.24.9 @@ -58,10 +58,6 @@ require ( github.com/ethereum/go-ethereum v1.9.13 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fxamacker/circlehash v0.3.0 // indirect - github.com/gammazero/deque v0.1.0 // indirect - github.com/go-kit/kit v0.12.0 // indirect - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/go-logr/logr v1.2.4 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect @@ -105,10 +101,8 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.19 // indirect - github.com/mattn/go-runewidth v0.0.14 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect github.com/minio/sha256-simd v1.0.1 // indirect - github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/mr-tron/base58 v1.2.0 // indirect github.com/multiformats/go-base32 v0.1.0 // indirect @@ -124,7 +118,6 @@ require ( github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20230711213910-baad011d2b13 // indirect github.com/onflow/sdks v0.5.0 // indirect - github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d // indirect github.com/opentracing/opentracing-go v1.2.0 // indirect github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 // indirect github.com/pelletier/go-toml/v2 v2.0.6 // indirect @@ -138,8 +131,8 @@ require ( github.com/rivo/uniseg v0.4.4 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/rs/cors v1.8.0 // indirect - github.com/schollz/progressbar/v3 v3.13.1 // indirect github.com/sethvargo/go-retry v0.2.3 // indirect + github.com/sirupsen/logrus v1.8.1 // indirect github.com/slok/go-http-metrics v0.10.0 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.9.3 // indirect @@ -171,7 +164,6 @@ require ( golang.org/x/net v0.12.0 // indirect golang.org/x/sync v0.3.0 // indirect golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect golang.org/x/time v0.1.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect @@ -193,3 +185,6 @@ require ( //TODO: Remove when both version will be merged replace github.com/onflow/flow-go v0.32.3 => github.com/Guitarheroua/flow-go v0.0.0-20231024184136-247768e776f7 + +//TODO: change this when flow-archive PR is merged +replace github.com/onflow/flow-archive => github.com/bluesign/flow-dps v1.4.8-0.20231107143842-75c6d48ac313 diff --git a/go.sum b/go.sum index db1ef62d..6bd7a9b4 100644 --- a/go.sum +++ b/go.sum @@ -27,18 +27,14 @@ cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aD cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.110.4 h1:1JYyxKMN9hd5dR2MYTPWkGUgcoxVVhg0LKNKEo0qvmk= cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/compute v1.21.0 h1:JNBsyXVoOoNJtTQcnEY5uYpZIbeCTYIeDe0Xh1bySMk= -cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/iam v1.1.1 h1:lW7fzj15aVIXYHREOqjRBV9PsH0Z6u8Y46a1YGvQP4Y= cloud.google.com/go/kms v1.0.0/go.mod h1:nhUehi+w7zht2XrUfvTRNpxrfayBHqP4lu2NSywui/0= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= @@ -50,7 +46,6 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= -cloud.google.com/go/storage v1.30.1 h1:uOdMxAs8HExqBlnLtnQyP0YkvbiDpdGShGKtx6U/oNM= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4= @@ -109,13 +104,6 @@ github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQ github.com/aws/aws-sdk-go v1.25.48/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= -github.com/aws/aws-sdk-go-v2 v1.17.7 h1:CLSjnhJSTSogvqUGhIC6LqFKATMRexcxLZ0i/Nzk9Eg= -github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.5.1 h1:VGkV9KmhGqOQWnHyi4gLG98kE6OecT42fdrCGFWxJsc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.3.0 h1:gceOysEWNNwLd6cki65IMBZ4WAM0MwgBQq2n7kejoT8= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.25 h1:5LHn8JQ0qvjD9L9JhMtylnkcw7j05GDZqM9Oin6hpr0= -github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.7.0 h1:HWsM0YQWX76V6MOp07YuTYacm8k7h69ObJuw7Nck+og= -github.com/aws/aws-sdk-go-v2/service/s3 v1.15.0 h1:nPLfLPfglacc29Y949sDxpr3X/blaY40s3B85WT2yZU= -github.com/aws/smithy-go v1.13.5 h1:hgz0X/DX0dGqTYpGALqXJoRKRj5oQ7150i5FdTePzO8= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/benbjohnson/clock v1.3.5 h1:VvXlSJBzZpA/zum6Sj74hxwYI2DIxRWuNIoXAzHZz5o= @@ -126,6 +114,8 @@ github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6r github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bits-and-blooms/bitset v1.5.0 h1:NpE8frKRLGHIcEzkR+gZhiioW1+WbYV6fKwD6ZIpQT8= github.com/bits-and-blooms/bitset v1.5.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA= +github.com/bluesign/flow-dps v1.4.8-0.20231107143842-75c6d48ac313 h1:QXHqnN6kt6z5/pb1ZeEaXNQFJvNYYAm1Pyp5CrM9iwE= +github.com/bluesign/flow-dps v1.4.8-0.20231107143842-75c6d48ac313/go.mod h1:i5TMmpHF6fSorwjsosaQIbax5RqJE5Q7eUZf/xfY+NM= github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6/go.mod h1:Dmm/EzmjnCiweXmzRIAiUWCInVmPgjkzgv5k4tVyXiQ= github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ= github.com/btcsuite/btcd/btcec/v2 v2.2.1 h1:xP60mv8fvp+0khmrN0zTdPC3cNm24rfeE6lh2R/Yv3E= @@ -284,8 +274,6 @@ github.com/fxamacker/circlehash v0.1.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5 github.com/fxamacker/circlehash v0.3.0 h1:XKdvTtIJV9t7DDUtsf0RIpC1OcxZtPbmgIH7ekx28WA= github.com/fxamacker/circlehash v0.3.0/go.mod h1:3aq3OfVvsWtkWMb6A1owjOQFA+TLsD5FgJflnaQwtMM= github.com/gabriel-vasile/mimetype v1.4.2 h1:w5qFW6JKBz9Y393Y4q372O9A7cUSequkh1Q7OhCmWKU= -github.com/gammazero/deque v0.1.0 h1:f9LnNmq66VDeuAlSAapemq/U7hJ2jpIWa4c09q8Dlik= -github.com/gammazero/deque v0.1.0/go.mod h1:KQw7vFau1hHuM8xmI9RbgKFbAsQFWmBpqQ2KenFLk6M= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -308,14 +296,11 @@ github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.10.0/go.mod h1:xUsJbQ/Fp4kEt7AFgCuvyX4a71u8h9jB8tj/ORgOZ7o= github.com/go-kit/kit v0.12.0 h1:e4o3o3IsBfAKQh5Qbbiqyfu97Ku7jrO/JbohvztANh4= -github.com/go-kit/kit v0.12.0/go.mod h1:lHd+EkCZPIwYItmGDDRdhinkzX2A1sj+M9biaEaizzs= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -366,7 +351,6 @@ github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4er github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= @@ -444,18 +428,15 @@ github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20230602150820-91b7bce49751 h1:hR7/MlvK23p6+lIw9SN1TigNLn9ZnF3W4SYRKq2gAHs= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.2.3 h1:yk9/cqRKtT9wXZSsRH9aurXEpJX+U6FLtpYTdC3R06k= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.11.0 h1:9V9PWXEsWnPpQhu/PeQIkS4eGzMlTLGgt80cUUI8Ki4= github.com/googleapis/google-cloud-go-testing v0.0.0-20200911160855-bcd43fbb19e8/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg= @@ -574,7 +555,6 @@ github.com/jbenet/goprocess v0.1.4 h1:DRGOFReOMqqDNXwW70QkacFW0YN9QnwLV0Vqk+3oU0 github.com/jbenet/goprocess v0.1.4/go.mod h1:5yspPrukOVuOLORacaBi858NqyClJPQxYZlqdZVfqY4= github.com/jessevdk/go-flags v0.0.0-20141203071132-1679536dcc89/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlTRt3OuAQ= @@ -694,7 +674,6 @@ github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcME github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -704,7 +683,6 @@ github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU= -github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-tty v0.0.3/go.mod h1:ihxohKRERHTVzN+aSVRwACLCeqIoZAWpoICkkvrWyR0= github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= @@ -795,8 +773,6 @@ github.com/onflow/atree v0.6.0/go.mod h1:gBHU0M05qCbv9NN0kijLWMgC47gHVNBIp4KmsVF github.com/onflow/cadence v0.20.1/go.mod h1:7mzUvPZUIJztIbr9eTvs+fQjWWHTF8veC+yk4ihcNIA= github.com/onflow/cadence v0.42.1 h1:Til0aa+TX2o9CM/0OFUPEssP0BoZBfpFRa4qefRgr0E= github.com/onflow/cadence v0.42.1/go.mod h1:raU8va8QRyTa/eUbhej4mbyW2ETePfSaywoo36MddgE= -github.com/onflow/flow-archive v1.3.4-0.20230503192214-9e81e82d4dcc h1:C4ZniFeOv+pHlDLJdGc/4e3NklSjVuvaXKN47980gnY= -github.com/onflow/flow-archive v1.3.4-0.20230503192214-9e81e82d4dcc/go.mod h1:UPsvKk/37Atosif4wlBl3gsLbGJyGpdXYpXDsWtMVBE= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f h1:S8yIZw9LFXfYD1V5H9BiixihHw3GrXVPrmfplSzYaww= github.com/onflow/flow-core-contracts/lib/go/contracts v1.2.4-0.20231016154253-a00dbf7c061f/go.mod h1:jM6GMAL+m0hjusUgiYDNrixPQ6b9s8xjoJQoEu5bHQI= github.com/onflow/flow-core-contracts/lib/go/templates v1.2.4-0.20231016154253-a00dbf7c061f h1:Ep+Mpo2miWMe4pjPGIaEvEzshRep30dvNgxqk+//FrQ= @@ -819,7 +795,6 @@ github.com/onflow/nft-storefront/lib/go/contracts v0.0.0-20221222181731-14b90207 github.com/onflow/sdks v0.5.0 h1:2HCRibwqDaQ1c9oUApnkZtEAhWiNY2GTpRD5+ftdkN8= github.com/onflow/sdks v0.5.0/go.mod h1:F0dj0EyHC55kknLkeD10js4mo14yTdMotnWMslPirrU= github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d h1:gAEqYPn3DS83rHIKEpsajnppVD1+zwuYPFyeDVFaQvg= -github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= @@ -949,7 +924,6 @@ github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFo github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= github.com/schollz/progressbar/v3 v3.8.3/go.mod h1:pWnVCjSBZsT2X3nx9HfRdnCDrpbevliMeoEVhStwHko= github.com/schollz/progressbar/v3 v3.13.1 h1:o8rySDYiQ59Mwzy2FELeHY5ZARXZTVJC7iHD6PEFUiE= -github.com/schollz/progressbar/v3 v3.13.1/go.mod h1:xvrbki8kfT1fzWzBT/UZd9L6GA+jdL7HAgq2RFnO6fQ= github.com/sclevine/agouti v3.0.0+incompatible/go.mod h1:b4WX9W9L1sfQKXeJf1mUTLZKJ48R1S7H23Ji7oFO5Bw= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= @@ -961,6 +935,7 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= github.com/slok/go-http-metrics v0.10.0 h1:rh0LaYEKza5eaYRGDXujKrOln57nHBi4TtVhmNEpbgM= github.com/slok/go-http-metrics v0.10.0/go.mod h1:lFqdaS4kWMfUKCSukjC47PdCeTk+hXDUVm8kLHRqJ38= github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= @@ -1255,7 +1230,6 @@ golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.10.0 h1:zHCpF2Khkwy4mMB4bv0U37YtJdTGW8jI0glAApi0Kh8= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1359,9 +1333,7 @@ golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210615171337-6886f2dfbf5b/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1490,7 +1462,6 @@ google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqiv google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= google.golang.org/api v0.58.0/go.mod h1:cAbP2FsxoGVNwtgNAmmn3y5G1TWAiVYRmg4yku3lv+E= -google.golang.org/api v0.126.0 h1:q4GJq+cAdMAC7XP7njvQ4tvohGLiSlytuL4BQxbIZ+o= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/server/server.go b/server/server.go index b13c8e66..d02fc284 100644 --- a/server/server.go +++ b/server/server.go @@ -310,6 +310,7 @@ func (s *EmulatorServer) Stop() { } func configureStorage(conf *Config) (storageProvider storage.Store, err error) { + if conf.RedisURL != "" { storageProvider, err = util.NewRedisStorage(conf.RedisURL) if err != nil { @@ -346,25 +347,17 @@ func configureStorage(conf *Config) (storageProvider storage.Store, err error) { } if conf.ChainID == flowgo.Testnet || conf.ChainID == flowgo.Mainnet { - // TODO: any reason redis shouldn't work? - baseProvider, ok := storageProvider.(*sqlite.Store) - if !ok { - return nil, fmt.Errorf("only sqlite is supported with forked networks") - } - provider, err := remote.New(baseProvider, remote.WithChainID(conf.ChainID)) + storageProvider, err = remote.New( + storageProvider, + remote.WithChainID(conf.ChainID), + remote.WithForkHeight(conf.StartBlockHeight), + ) + if err != nil { return nil, err } - if conf.StartBlockHeight > 0 { - err = provider.SetBlockHeight(conf.StartBlockHeight) - if err != nil { - return nil, err - } - } - - storageProvider = provider } if conf.Snapshot { diff --git a/server/utils/emulator.go b/server/utils/emulator.go index 7122f91c..3d6fbb3b 100644 --- a/server/utils/emulator.go +++ b/server/utils/emulator.go @@ -127,6 +127,7 @@ func (m EmulatorAPIServer) Rollback(w http.ResponseWriter, r *http.Request) { err = m.emulator.RollbackToBlockHeight(height) if err != nil { w.WriteHeader(http.StatusInternalServerError) + _, _ = w.Write([]byte(err.Error())) return } diff --git a/storage/memstore/memstore.go b/storage/memstore/memstore.go index 628e34ae..d491095c 100644 --- a/storage/memstore/memstore.go +++ b/storage/memstore/memstore.go @@ -67,6 +67,11 @@ func New() *Store { var _ storage.Store = &Store{} +func (s *Store) SetBlockHeight(height uint64) error { + //mem-store does not support SetBlockHeight + return nil +} + func (s *Store) Start() error { return nil } diff --git a/storage/mocks/store.go b/storage/mocks/store.go index 4b9b5b5a..d56377fd 100644 --- a/storage/mocks/store.go +++ b/storage/mocks/store.go @@ -156,6 +156,20 @@ func (mr *MockStoreMockRecorder) LedgerByHeight(arg0, arg1 interface{}) *gomock. return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LedgerByHeight", reflect.TypeOf((*MockStore)(nil).LedgerByHeight), arg0, arg1) } +// SetBlockHeight mocks base method. +func (m *MockStore) SetBlockHeight(arg0 uint64) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "SetBlockHeight", arg0) + ret0, _ := ret[0].(error) + return ret0 +} + +// SetBlockHeight indicates an expected call of SetBlockHeight. +func (mr *MockStoreMockRecorder) SetBlockHeight(arg0 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetBlockHeight", reflect.TypeOf((*MockStore)(nil).SetBlockHeight), arg0) +} + // Start mocks base method. func (m *MockStore) Start() error { m.ctrl.T.Helper() diff --git a/storage/remote/store.go b/storage/remote/store.go index faae4c06..bde2f9ae 100644 --- a/storage/remote/store.go +++ b/storage/remote/store.go @@ -21,30 +21,84 @@ package remote import ( "context" "fmt" - "github.com/onflow/flow-archive/api/archive" + archive "github.com/onflow/flow-archive/api/archive/client" "github.com/onflow/flow-archive/codec/zbor" "github.com/onflow/flow-go/fvm/errors" "github.com/onflow/flow-go/fvm/storage/snapshot" - "github.com/onflow/flow-go/ledger/common/convert" - "github.com/onflow/flow-go/ledger/common/pathfinder" - "github.com/onflow/flow-go/ledger/complete" flowgo "github.com/onflow/flow-go/model/flow" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" "github.com/onflow/flow-emulator/storage" - "github.com/onflow/flow-emulator/storage/sqlite" ) type Store struct { - *sqlite.Store - client archive.APIClient - grpcConn *grpc.ClientConn - host string + storage.DefaultStore + forkedStore storage.Store + archiveClient archive.APIClient + grpcConn *grpc.ClientConn + archiveHost string + forkHeight uint64 +} + +func (s *Store) SetBlockHeight(height uint64) error { + + if height < s.forkHeight { + s.forkHeight = height + } + + return s.forkedStore.SetBlockHeight(height) +} + +func (s *Store) RollbackToBlockHeight(height uint64) error { + rollbackProvider, isRollbackProvider := s.forkedStore.(storage.RollbackProvider) + if !isRollbackProvider { + return fmt.Errorf("storage provider does not support rollback") + } + err := rollbackProvider.RollbackToBlockHeight(height) + if err != nil { + return err + } + return s.SetBlockHeight(height) +} + +func (s *Store) Snapshots() ([]string, error) { + snapshotProvider, isSnapshotShotProvider := s.forkedStore.(storage.SnapshotProvider) + if !isSnapshotShotProvider { + return []string{}, fmt.Errorf("storage provider does not support snapshots") + } + return snapshotProvider.Snapshots() +} + +func (s *Store) CreateSnapshot(snapshotName string) error { + snapshotProvider, isSnapshotShotProvider := s.forkedStore.(storage.SnapshotProvider) + if !isSnapshotShotProvider { + return fmt.Errorf("storage provider does not support snapshots") + } + return snapshotProvider.CreateSnapshot(snapshotName) +} + +func (s *Store) LoadSnapshot(snapshotName string) error { + snapshotProvider, isSnapshotShotProvider := s.forkedStore.(storage.SnapshotProvider) + if !isSnapshotShotProvider { + return fmt.Errorf("storage provider does not support snapshots") + } + return snapshotProvider.LoadSnapshot(snapshotName) +} + +func (s *Store) SupportSnapshotsWithCurrentConfig() bool { + snapshotProvider, isSnapshotShotProvider := s.forkedStore.(storage.SnapshotProvider) + if !isSnapshotShotProvider { + return false + } + return snapshotProvider.SupportSnapshotsWithCurrentConfig() } type Option func(*Store) +var _ storage.SnapshotProvider = &Store{} +var _ storage.RollbackProvider = &Store{} + // WithChainID sets a chain ID and is used to determine which archive node to use. func WithChainID(ID flowgo.ChainID) Option { return func(store *Store) { @@ -53,42 +107,50 @@ func WithChainID(ID flowgo.ChainID) Option { flowgo.Testnet: "archive.testnet.nodes.onflow.org:9000", } - store.host = archiveHosts[ID] + store.archiveHost = archiveHosts[ID] } } -// WithHost sets archive node host. +// WithHost sets archive node archiveHost. func WithHost(host string) Option { return func(store *Store) { - store.host = host + store.archiveHost = host + } +} + +// WithForkHeight sets height to fork chain. +func WithForkHeight(height uint64) Option { + return func(store *Store) { + store.forkHeight = height } } -// WithClient can set an archive node client +// WithClient can set an archive node archiveClient // // This is mostly use for testing. func WithClient(client archive.APIClient) Option { return func(store *Store) { - store.client = client + store.archiveClient = client } } -func New(provider *sqlite.Store, options ...Option) (*Store, error) { +func New(provider storage.Store, options ...Option) (*Store, error) { store := &Store{ - Store: provider, + forkedStore: provider, + forkHeight: 0, } for _, opt := range options { opt(store) } - if store.client == nil { - if store.host == "" { - return nil, fmt.Errorf("archive node host must be provided") + if store.archiveClient == nil { + if store.archiveHost == "" { + return nil, fmt.Errorf("archive node archiveHost must be provided") } conn, err := grpc.Dial( - store.host, + store.archiveHost, grpc.WithTransportCredentials(insecure.NewCredentials()), ) if err != nil { @@ -96,90 +158,110 @@ func New(provider *sqlite.Store, options ...Option) (*Store, error) { } store.grpcConn = conn - store.client = archive.NewAPIClient(conn) + store.archiveClient = archive.NewAPIClient(conn) } - store.DataGetter = store - store.DataSetter = store + if store.forkHeight == 0 { + // check persist + lastHeight, err := store.forkedStore.LatestBlockHeight(context.Background()) + if err != nil { + // if it's not set yet, get the block height at fork point + heightRes, err := store.archiveClient.GetLast(context.Background(), &archive.GetLastRequest{}) + if err != nil { + return nil, err + } + store.forkHeight = heightRes.Height + } else { + store.forkHeight = lastHeight + } + err = store.SetBlockHeight(store.forkHeight) + if err != nil { + return nil, err + } + } + + store.DataGetter = store.forkedStore.(storage.DataGetter) + store.DataSetter = store.forkedStore.(storage.DataSetter) store.KeyGenerator = &storage.DefaultKeyGenerator{} return store, nil } func (s *Store) BlockByID(ctx context.Context, blockID flowgo.Identifier) (*flowgo.Block, error) { - var height uint64 - block, err := s.DefaultStore.BlockByID(ctx, blockID) + block, err := s.forkedStore.BlockByID(ctx, blockID) if err == nil { - height = block.Header.Height - } else if errors.Is(err, storage.ErrNotFound) { - heightRes, err := s.client.GetHeightForBlock(ctx, &archive.GetHeightForBlockRequest{BlockID: blockID[:]}) - if err != nil { - return nil, err - } - height = heightRes.Height - } else { - return nil, err + return block, nil } - return s.BlockByHeight(ctx, height) -} + if !errors.Is(err, storage.ErrNotFound) { + return nil, err + } -func (s *Store) LatestBlock(ctx context.Context) (flowgo.Block, error) { - // try to resume from the last local block - latestBlockHeight, err := s.LatestBlockHeight(ctx) - if err != nil && !errors.Is(err, storage.ErrNotFound) { - return flowgo.Block{}, err + //not found on fork + heightRes, err := s.archiveClient.GetHeightForBlock(ctx, &archive.GetHeightForBlockRequest{BlockID: blockID[:]}) + if err != nil { + return nil, err } - // if it's not set yet, get the latest block available from the archive node - if latestBlockHeight == 0 { - heightRes, err := s.client.GetLast(ctx, &archive.GetLastRequest{}) - if err != nil { - return flowgo.Block{}, err - } - latestBlockHeight = heightRes.Height + if heightRes.Height > s.forkHeight { + //return 'not found' for blocks after fork + return nil, storage.ErrNotFound } + return s.BlockByHeight(ctx, heightRes.Height) +} - block, err := s.BlockByHeight(ctx, latestBlockHeight) +func (s *Store) LatestBlock(ctx context.Context) (block flowgo.Block, err error) { + block, err = s.forkedStore.LatestBlock(ctx) + if err == nil { + return block, nil + } + if !errors.Is(err, storage.ErrNotFound) { + return flowgo.Block{}, err + } + //if no block on fork, ask archive + aBlock, err := s.BlockByHeight(ctx, s.forkHeight) if err != nil { return flowgo.Block{}, err } - - return *block, nil + return *aBlock, nil } func (s *Store) BlockByHeight(ctx context.Context, height uint64) (*flowgo.Block, error) { - block, err := s.DefaultStore.BlockByHeight(ctx, height) - if err == nil { - return block, nil - } - blockRes, err := s.client.GetHeader(ctx, &archive.GetHeaderRequest{Height: height}) - if err != nil { - return nil, err + if height <= s.forkHeight { + //get block from archive node + blockRes, err := s.archiveClient.GetHeader(ctx, &archive.GetHeaderRequest{Height: height}) + if err != nil { + return nil, err + } + + var header flowgo.Header + err = zbor.NewCodec().Unmarshal(blockRes.Data, &header) + if err != nil { + return nil, err + } + + payload := flowgo.EmptyPayload() + return &flowgo.Block{ + Payload: &payload, + Header: &header, + }, nil } - var header flowgo.Header - err = zbor.NewCodec().Unmarshal(blockRes.Data, &header) + //get block from local fork + block, err := s.forkedStore.BlockByHeight(ctx, height) if err != nil { return nil, err } - payload := flowgo.EmptyPayload() - return &flowgo.Block{ - Payload: &payload, - Header: &header, - }, nil + return block, nil + } func (s *Store) LedgerByHeight( ctx context.Context, blockHeight uint64, ) (snapshot.StorageSnapshot, error) { - err := s.SetBlockHeight(blockHeight) - if err != nil { - return nil, err - } return snapshot.NewReadFuncStorageSnapshot(func(id flowgo.RegisterID) (flowgo.RegisterValue, error) { // first try to see if we have local stored ledger @@ -193,16 +275,10 @@ func (s *Store) LedgerByHeight( return value, nil } - ledgerKey := convert.RegisterIDToLedgerKey(flowgo.RegisterID{Key: id.Key, Owner: id.Owner}) - ledgerPath, err := pathfinder.KeyToPath(ledgerKey, complete.DefaultPathFinderVersion) - if err != nil { - return nil, err - } - - // if we don't have it, get it from the archive node - response, err := s.client.GetRegisterValues(ctx, &archive.GetRegisterValuesRequest{ - Height: blockHeight, - Paths: [][]byte{ledgerPath[:]}, + reg := flowgo.RegisterID{Key: id.Key, Owner: id.Owner} + response, err := s.archiveClient.GetRegisterValues(ctx, &archive.GetRegisterValuesRequest{ + Height: blockHeight, + Registers: [][]byte{reg.Bytes()}, }) if err != nil { return nil, err diff --git a/storage/remote/store_test.go b/storage/remote/store_test.go index 722e6fcf..9204c6f2 100644 --- a/storage/remote/store_test.go +++ b/storage/remote/store_test.go @@ -30,9 +30,12 @@ import ( "github.com/onflow/flow-emulator/adapters" "github.com/onflow/flow-emulator/storage/sqlite" - "github.com/onflow/flow-archive/api/archive" + archive "github.com/onflow/flow-archive/api/archive/client" "github.com/onflow/flow-archive/codec/zbor" flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go/ledger/common/convert" + "github.com/onflow/flow-go/ledger/common/pathfinder" + "github.com/onflow/flow-go/model/encoding/rlp" flowgo "github.com/onflow/flow-go/model/flow" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -41,6 +44,16 @@ import ( emulator "github.com/onflow/flow-emulator/emulator" ) +func BytesToRegister(b []byte) (*flowgo.RegisterID, error) { + var decoded flowgo.RegisterID + unmarshaler := rlp.NewMarshaler() + err := unmarshaler.Unmarshal(b, &decoded) + if err != nil { + return nil, fmt.Errorf("could not decode register ID: %w", err) + } + return &decoded, nil +} + var _ archive.APIClient = testClient{} const testHeight = uint64(53115699) @@ -107,14 +120,21 @@ func (a testClient) GetEvents(ctx context.Context, in *archive.GetEventsRequest, } func (a testClient) GetRegisterValues(ctx context.Context, in *archive.GetRegisterValuesRequest, opts ...grpc.CallOption) (*archive.GetRegisterValuesResponse, error) { - val, ok := a.registerMap[hex.EncodeToString(in.Paths[0])] + for key := range a.registerMap { + fmt.Println(key) + } + + regBytes := in.Registers[0] + register, _ := BytesToRegister(regBytes) + key := convert.RegisterIDToLedgerKey(*register) + path, _ := pathfinder.KeyToPath(key, 1) + val, ok := a.registerMap[hex.EncodeToString(path[:])] + if !ok { return nil, fmt.Errorf("register not found in test fixture") } return &archive.GetRegisterValuesResponse{ - Height: in.Height, - Paths: in.Paths, Values: [][]byte{val}, }, nil } diff --git a/storage/sqlite/store.go b/storage/sqlite/store.go index f5939e80..edbdc9e1 100644 --- a/storage/sqlite/store.go +++ b/storage/sqlite/store.go @@ -242,7 +242,8 @@ func (s *Store) SupportSnapshotsWithCurrentConfig() bool { } func (s *Store) GetBytes(ctx context.Context, store string, key []byte) ([]byte, error) { - return s.GetBytesAtVersion(ctx, store, key, 0) + v, err := s.GetBytesAtVersion(ctx, store, key, 0) + return v, err } func (s *Store) SetBytes(ctx context.Context, store string, key []byte, value []byte) error { diff --git a/storage/store.go b/storage/store.go index 1d08e90a..547eddb4 100644 --- a/storage/store.go +++ b/storage/store.go @@ -101,6 +101,8 @@ type Store interface { // EventsByHeight returns the events in the block at the given height, optionally filtered by type. EventsByHeight(ctx context.Context, blockHeight uint64, eventType string) ([]flowgo.Event, error) + + SetBlockHeight(height uint64) error } type SnapshotProvider interface {