From 057a756f9902190c6f1f37c4b6e3704e42150a25 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Tue, 20 Feb 2024 20:30:04 +0100 Subject: [PATCH 1/9] update deps to latest evm --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 4407c1a17..672789679 100644 --- a/go.mod +++ b/go.mod @@ -178,11 +178,11 @@ require ( github.com/onflow/crypto v0.25.0 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 // indirect - github.com/onflow/flow-go v0.33.2-0.20240214203221-b11eeaa896bd // indirect + github.com/onflow/flow-go v0.33.2-0.20240220142056-d1573c75f26c // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6 // indirect github.com/onflow/flow/protobuf/go/flow v0.3.7 // indirect github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect - github.com/onflow/wal v0.0.0-20230529184820-bc9f8244608d // indirect + github.com/onflow/wal v0.0.0-20240208022732-d756cd497d3b // 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.8 // indirect diff --git a/go.sum b/go.sum index 9fa6bc639..1fa0f8982 100644 --- a/go.sum +++ b/go.sum @@ -2071,8 +2071,8 @@ github.com/onflow/flow-emulator v1.0.0-M5 h1:yPx6je/ahdYvd4b80bMXJ0AT4k2eogEGsQC github.com/onflow/flow-emulator v1.0.0-M5/go.mod h1:CBp/YrgR2PeOdqhQMbfAiznGayNoJuFQTfLV9EJFtEc= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 h1:u6/YcUvO8jU0f3Evb/6agzXqeOo+VbL2a3mmj/5ifRs= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= -github.com/onflow/flow-go v0.33.2-0.20240214203221-b11eeaa896bd h1:x9eOt5rdDSr00aKwoyUWyJ4m8WlUwgYoV94oSEWPhiM= -github.com/onflow/flow-go v0.33.2-0.20240214203221-b11eeaa896bd/go.mod h1:45DIkRx5a+qiV83fpJ+fra9WtRiF4bTqd7XMxahRdnc= +github.com/onflow/flow-go v0.33.2-0.20240220142056-d1573c75f26c h1:CTZt67woYFum9JkBlCUI8bRh3hUElkzp5HveP3Q6/aE= +github.com/onflow/flow-go v0.33.2-0.20240220142056-d1573c75f26c/go.mod h1:ClmIYh0WtY5Ait0en/F4p/Ha9s3DyFryu7AdpN0aoM0= github.com/onflow/flow-go-sdk v1.0.0-M1/go.mod h1:TDW0MNuCs4SvqYRUzkbRnRmHQL1h4X8wURsCw9P9beo= github.com/onflow/flow-go-sdk v1.0.0-M4 h1:dGtgZvaIfBR5/9I9nm5nLm69V5pLcSz9vXmzCb1lyzM= github.com/onflow/flow-go-sdk v1.0.0-M4/go.mod h1:HIGOKJVR47QNs81sPHmZDVcLr+syNkmbgEMLQGDmmEo= @@ -2085,8 +2085,8 @@ github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.2.0.20240214213743-ee40 github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.2.0.20240214213743-ee40994a815f/go.mod h1:Ck+iZGJYerviTQ3SyqoUNLNXdRUJiI5iMxfM9YugtK0= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba h1:rIehuhO6bj4FkwE4VzwEjX7MoAlOhUJENBJLqDqVxAo= github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba/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/onflow/wal v0.0.0-20240208022732-d756cd497d3b h1:6O/BEmA99PDT5QVjoJgrYlGsWnpxGJTAMmsC+V9gyds= +github.com/onflow/wal v0.0.0-20240208022732-d756cd497d3b/go.mod h1:iMC8gkLqu4nkbkAla5HkSBb+FGyQOZiWz3DYm2wSXCk= github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48 h1:eBS8Rm1V9TTGpj9lcpoCi6MIwWgYQZ8crJ7cSrS39Y4= github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48/go.mod h1:Pvw+OkV3eqLGMpHWu38rJYE30N9G3VgQ2MRQQnRr4to= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= From 67c05e829469e9502bd784db2e66e9c301fe91fe Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Tue, 20 Feb 2024 21:22:15 +0100 Subject: [PATCH 2/9] add gateway --- go.mod | 3 ++- go.sum | 12 ++++++---- internal/evm-gateway/gateway.go | 39 +++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 internal/evm-gateway/gateway.go diff --git a/go.mod b/go.mod index 672789679..1607e2229 100644 --- a/go.mod +++ b/go.mod @@ -16,6 +16,7 @@ require ( github.com/onflow/flixkit-go v1.1.1-0.20240214222351-03b90f7d32ef github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7 github.com/onflow/flow-emulator v1.0.0-M5 + github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd github.com/onflow/flow-go-sdk v1.0.0-M4 github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.2.0.20240214213743-ee40994a815f github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48 @@ -199,7 +200,7 @@ require ( github.com/rivo/uniseg v0.4.4 // indirect github.com/rogpeppe/go-internal v1.11.0 // indirect github.com/rs/cors v1.8.0 // indirect - github.com/rs/zerolog v1.29.0 // indirect + github.com/rs/zerolog v1.31.0 // indirect github.com/sethvargo/go-retry v0.2.3 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/skeema/knownhosts v1.2.1 // indirect diff --git a/go.sum b/go.sum index 1fa0f8982..8702a8714 100644 --- a/go.sum +++ b/go.sum @@ -1183,8 +1183,8 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e h1:Wf6HqHfScWJN9/ZjdUKyjop4mf3Qdd+1TvvltAvM3m8= github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8iXXhfZs= +github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= @@ -2069,6 +2069,10 @@ github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101- github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7/go.mod h1:MZ2j5YVTQiSE0B99zuaYhxvGG5GcvimWpQK1Fw/1QBg= github.com/onflow/flow-emulator v1.0.0-M5 h1:yPx6je/ahdYvd4b80bMXJ0AT4k2eogEGsQCOI+83V2I= github.com/onflow/flow-emulator v1.0.0-M5/go.mod h1:CBp/YrgR2PeOdqhQMbfAiznGayNoJuFQTfLV9EJFtEc= +github.com/onflow/flow-evm-gateway v0.0.0-20240220193433-be37111287b7 h1:aHj738RK56xDPw/uzUIoEHCqHYerQrHjx9FFnNscniY= +github.com/onflow/flow-evm-gateway v0.0.0-20240220193433-be37111287b7/go.mod h1:0kkEyZ+/EMsJ/4q0rjp9gghS9zTYmrWBJlPVsxkJhXc= +github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd h1:qMoEHY8AfwN4Sp6kQL2rPZfEJnOBGXZyitQQmp9dEQE= +github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd/go.mod h1:Z9bmG2qxOi8hbLAzhQHh3jFCv2fQR4dV8F7N5JL572w= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 h1:u6/YcUvO8jU0f3Evb/6agzXqeOo+VbL2a3mmj/5ifRs= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-go v0.33.2-0.20240220142056-d1573c75f26c h1:CTZt67woYFum9JkBlCUI8bRh3hUElkzp5HveP3Q6/aE= @@ -2235,10 +2239,10 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/cors v1.8.0 h1:P2KMzcFwrPoSjkF1WLRPsp3UMLyql8L4v9hQpVeK5so= github.com/rs/cors v1.8.0/go.mod h1:EBwu+T5AvHOcXwvZIkQFjUN6s8Czyqw12GL/Y0tUyRM= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= -github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= -github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= +github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= +github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= diff --git a/internal/evm-gateway/gateway.go b/internal/evm-gateway/gateway.go new file mode 100644 index 000000000..1a9b3a6fa --- /dev/null +++ b/internal/evm-gateway/gateway.go @@ -0,0 +1,39 @@ +package evm_gateway + +import ( + "github.com/onflow/flow-evm-gateway/bootstrap" + "github.com/onflow/flow-evm-gateway/config" + "github.com/onflow/flowkit/v2" + "github.com/onflow/flowkit/v2/output" + "github.com/spf13/cobra" + + "github.com/onflow/flow-cli/internal/command" +) + +type GatewayFlag struct{} + +var gatewyFlag = GatewayFlag{} + +var GatewayCmd = &command.Command{ + Cmd: &cobra.Command{ + Use: "snapshot [snapshotName]", + Short: "Create/Load/List emulator snapshots", + Example: "flow emulator snapshot create testSnapshot", + Args: cobra.RangeArgs(1, 2), + }, + Flags: &gatewyFlag, + Run: func( + args []string, + globalFlags command.GlobalFlags, + logger output.Logger, + readerWriter flowkit.ReaderWriter, + flow flowkit.Services, + ) (command.Result, error) { + cfg, err := config.FromFlags() + if err != nil { + return nil, err + } + + return nil, bootstrap.Start(cfg) + }, +} From db801fd68d6143ff1e024e574ded7abe26b2a56d Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Tue, 20 Feb 2024 21:24:30 +0100 Subject: [PATCH 3/9] add cmd --- cmd/flow/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/flow/main.go b/cmd/flow/main.go index 3dbf7809b..98662a2dc 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -21,6 +21,7 @@ package main import ( "fmt" + evm_gateway "github.com/onflow/flow-cli/internal/evm-gateway" "os" "strings" @@ -122,6 +123,7 @@ func main() { cmd.AddCommand(super.GenerateCommand) cmd.AddCommand(dependencymanager.Cmd) cmd.AddCommand(migrate.Cmd) + cmd.AddCommand(evm_gateway.GatewayCmd.Cmd) command.InitFlags(cmd) cmd.AddGroup(&cobra.Group{ From 1d2d44c47a7862d2985899820603772a0913c303 Mon Sep 17 00:00:00 2001 From: Gregor Gololicic Date: Tue, 20 Feb 2024 21:37:42 +0100 Subject: [PATCH 4/9] parse flags --- cmd/flow/main.go | 7 +-- go.mod | 4 ++ go.sum | 20 ++++++- internal/evm-gateway/gateway.go | 39 ------------- internal/evm/gateway.go | 99 +++++++++++++++++++++++++++++++++ 5 files changed, 124 insertions(+), 45 deletions(-) delete mode 100644 internal/evm-gateway/gateway.go create mode 100644 internal/evm/gateway.go diff --git a/cmd/flow/main.go b/cmd/flow/main.go index 98662a2dc..6744ced33 100644 --- a/cmd/flow/main.go +++ b/cmd/flow/main.go @@ -21,12 +21,9 @@ package main import ( "fmt" - evm_gateway "github.com/onflow/flow-cli/internal/evm-gateway" "os" "strings" - "github.com/onflow/flow-cli/internal/dependencymanager" - "github.com/spf13/cobra" "github.com/onflow/flow-cli/internal/accounts" @@ -35,8 +32,10 @@ import ( "github.com/onflow/flow-cli/internal/collections" "github.com/onflow/flow-cli/internal/command" "github.com/onflow/flow-cli/internal/config" + "github.com/onflow/flow-cli/internal/dependencymanager" "github.com/onflow/flow-cli/internal/emulator" "github.com/onflow/flow-cli/internal/events" + evm "github.com/onflow/flow-cli/internal/evm" "github.com/onflow/flow-cli/internal/keys" "github.com/onflow/flow-cli/internal/migrate" "github.com/onflow/flow-cli/internal/project" @@ -123,7 +122,7 @@ func main() { cmd.AddCommand(super.GenerateCommand) cmd.AddCommand(dependencymanager.Cmd) cmd.AddCommand(migrate.Cmd) - cmd.AddCommand(evm_gateway.GatewayCmd.Cmd) + cmd.AddCommand(evm.Cmd) command.InitFlags(cmd) cmd.AddGroup(&cobra.Group{ diff --git a/go.mod b/go.mod index 1607e2229..892c1aa08 100644 --- a/go.mod +++ b/go.mod @@ -84,6 +84,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect github.com/fxamacker/circlehash v0.3.0 // indirect + github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect github.com/glebarez/go-sqlite v1.22.0 // indirect github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect github.com/go-git/go-billy/v5 v5.5.0 // indirect @@ -122,6 +123,7 @@ require ( github.com/hashicorp/hcl v1.0.0 // indirect github.com/holiman/bloomfilter/v2 v2.0.3 // indirect github.com/holiman/uint256 v1.2.3 // indirect + github.com/huin/goupnp v1.3.0 // indirect github.com/iancoleman/orderedmap v0.0.0-20190318233801-ac98e3ecb4b0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect @@ -137,6 +139,7 @@ require ( github.com/ipfs/go-log v1.0.5 // indirect github.com/ipfs/go-log/v2 v2.5.1 // indirect github.com/ipfs/go-metrics-interface v0.0.1 // indirect + github.com/jackpal/go-nat-pmp v1.0.2 // indirect github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect github.com/jbenet/go-temp-err-catcher v0.1.0 // indirect github.com/jbenet/goprocess v0.1.4 // indirect @@ -211,6 +214,7 @@ require ( github.com/spf13/cast v1.5.1 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/pflag v1.0.5 // indirect + github.com/status-im/keycard-go v0.2.0 // indirect github.com/stoewer/go-strcase v1.3.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/subosito/gotenv v1.4.2 // indirect diff --git a/go.sum b/go.sum index 8702a8714..c03168fd9 100644 --- a/go.sum +++ b/go.sum @@ -1105,6 +1105,7 @@ github.com/cenkalti/backoff/v4 v4.2.1/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyY github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.3.0/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= +github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko= github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= @@ -1187,10 +1188,12 @@ github.com/coreos/go-systemd/v22 v22.5.0 h1:RrqgGjYQKalulkV8NGVIfkXQf6YYmOyiJKk8 github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man v1.0.10 h1:BSKMNlYxDvnunlTymqtgONjNnaRV1sTpcovwwjF22jk= github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= +github.com/cpuguy83/go-md2man/v2 v2.0.3 h1:qMCsGGgs+MAzDFyp9LpAe1Lqy/fY/qCovCm0qnXZOBM= github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/crate-crypto/go-ipa v0.0.0-20230601170251-1830d0757c80/go.mod h1:gzbVz57IDJgQ9rLQwfSk696JGWof8ftznEL9GoAv3NI= github.com/crate-crypto/go-kzg-4844 v0.7.0 h1:C0vgZRk4q4EZ/JgPfzuSoxdCq3C3mOZMBShovmncxvA= @@ -1306,6 +1309,7 @@ github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY= github.com/fjl/gencodec v0.0.0-20230517082657-f9840df7b83e/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/flosch/pongo2 v0.0.0-20190707114632-bbf5a6c351f4/go.mod h1:T9YF2M40nIgbVgp3rreNmTged+9HrbNTIQf1PsaIiTA= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= @@ -1328,6 +1332,7 @@ github.com/gammazero/deque v0.1.0 h1:f9LnNmq66VDeuAlSAapemq/U7hJ2jpIWa4c09q8Dlik github.com/gammazero/workerpool v1.1.2 h1:vuioDQbgrz4HoaCi2q1HLlOXdpbap5AET7xu5/qj87g= github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8= github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/gballet/go-verkle v0.0.0-20230607174250-df487255f46b/go.mod h1:CDncRYVRSDqwakm282WEkjfaAj1hxU/v5RXxk5nXOiI= github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4= @@ -1447,10 +1452,12 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/gogo/status v1.1.0/go.mod h1:BFv9nrluPLmrS0EmGVvLaPNmRosr9KapBYd5/hpY1WM= github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= github.com/golang-jwt/jwt/v4 v4.2.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang-jwt/jwt/v4 v4.4.3/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= @@ -1645,6 +1652,7 @@ github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyN github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= @@ -1687,6 +1695,7 @@ github.com/holiman/uint256 v1.2.3/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZm github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= +github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc= github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8= github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o= github.com/hydrogen18/memlistener v0.0.0-20141126152155-54553eb933fb/go.mod h1:qEIFzExnS6016fRpRfxrExeVn2gbClQA99gQhnIcdhE= @@ -1753,6 +1762,7 @@ github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62 github.com/iris-contrib/jade v1.1.3/go.mod h1:H/geBymxJhShH5kecoiOCSssPX7QWYH7UaeZTSWddIk= github.com/iris-contrib/pongo2 v0.0.1/go.mod h1:Ssh+00+3GAZqSQb30AvBRNxBx7rf0GqwkjqxNd0u65g= github.com/iris-contrib/schema v0.0.1/go.mod h1:urYA3uvUNG1TIIjOSCzHr9/LmbQo8LrOcOqfqxa4hXw= +github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= @@ -1977,6 +1987,7 @@ github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY= github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU= @@ -2069,8 +2080,6 @@ github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101- github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7/go.mod h1:MZ2j5YVTQiSE0B99zuaYhxvGG5GcvimWpQK1Fw/1QBg= github.com/onflow/flow-emulator v1.0.0-M5 h1:yPx6je/ahdYvd4b80bMXJ0AT4k2eogEGsQCOI+83V2I= github.com/onflow/flow-emulator v1.0.0-M5/go.mod h1:CBp/YrgR2PeOdqhQMbfAiznGayNoJuFQTfLV9EJFtEc= -github.com/onflow/flow-evm-gateway v0.0.0-20240220193433-be37111287b7 h1:aHj738RK56xDPw/uzUIoEHCqHYerQrHjx9FFnNscniY= -github.com/onflow/flow-evm-gateway v0.0.0-20240220193433-be37111287b7/go.mod h1:0kkEyZ+/EMsJ/4q0rjp9gghS9zTYmrWBJlPVsxkJhXc= github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd h1:qMoEHY8AfwN4Sp6kQL2rPZfEJnOBGXZyitQQmp9dEQE= github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd/go.mod h1:Z9bmG2qxOi8hbLAzhQHh3jFCv2fQR4dV8F7N5JL572w= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 h1:u6/YcUvO8jU0f3Evb/6agzXqeOo+VbL2a3mmj/5ifRs= @@ -2243,8 +2252,10 @@ github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.19.0/go.mod h1:IzD0RJ65iWH0w97OQQebJEvTZYvsCUm9WVLWBQrJRjo= github.com/rs/zerolog v1.31.0 h1:FcTR3NnLWW+NnTwwhFWiJSZr4ECLpqCm6QsEnyvbV4A= github.com/rs/zerolog v1.31.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss= +github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ruudk/golang-pdf417 v0.0.0-20181029194003-1af4ab5afa58/go.mod h1:6lfFZQK844Gfx8o5WFuvpxWRwnSoipWe/p622j1v06w= github.com/ruudk/golang-pdf417 v0.0.0-20201230142125-a7e3863a1245/go.mod h1:pQAZKsJ8yyVxGRWYNEm9oFB8ieLgKFnamEyDmSA0BRk= @@ -2316,6 +2327,7 @@ github.com/spf13/viper v1.4.0/go.mod h1:PTJ7Z/lr49W6bUbkmS1V3by4uWynFiR9p7+dSq/y github.com/spf13/viper v1.16.0 h1:rGGH0XDZhdUOryiDWjmIvUSWpbNqisK8Wk0Vyefw8hc= github.com/spf13/viper v1.16.0/go.mod h1:yg78JgCJcbrQOvV9YLXgkLaZqUidkY9K+Dd1FofRzQg= github.com/status-im/keycard-go v0.0.0-20190316090335-8537d3370df4/go.mod h1:RZLeN1LMWmRsyYjvAu+I6Dm9QmlDaIIt+Y+4Kd7Tp+Q= +github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= @@ -2378,10 +2390,12 @@ github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljT github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= +github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo= github.com/urfave/cli/v2 v2.24.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc= +github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs= github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ= github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= @@ -2406,6 +2420,7 @@ github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= @@ -3410,6 +3425,7 @@ gopkg.in/ini.v1 v1.51.1/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/mgo.v2 v2.0.0-20180705113604-9856a29383ce/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= diff --git a/internal/evm-gateway/gateway.go b/internal/evm-gateway/gateway.go deleted file mode 100644 index 1a9b3a6fa..000000000 --- a/internal/evm-gateway/gateway.go +++ /dev/null @@ -1,39 +0,0 @@ -package evm_gateway - -import ( - "github.com/onflow/flow-evm-gateway/bootstrap" - "github.com/onflow/flow-evm-gateway/config" - "github.com/onflow/flowkit/v2" - "github.com/onflow/flowkit/v2/output" - "github.com/spf13/cobra" - - "github.com/onflow/flow-cli/internal/command" -) - -type GatewayFlag struct{} - -var gatewyFlag = GatewayFlag{} - -var GatewayCmd = &command.Command{ - Cmd: &cobra.Command{ - Use: "snapshot [snapshotName]", - Short: "Create/Load/List emulator snapshots", - Example: "flow emulator snapshot create testSnapshot", - Args: cobra.RangeArgs(1, 2), - }, - Flags: &gatewyFlag, - Run: func( - args []string, - globalFlags command.GlobalFlags, - logger output.Logger, - readerWriter flowkit.ReaderWriter, - flow flowkit.Services, - ) (command.Result, error) { - cfg, err := config.FromFlags() - if err != nil { - return nil, err - } - - return nil, bootstrap.Start(cfg) - }, -} diff --git a/internal/evm/gateway.go b/internal/evm/gateway.go new file mode 100644 index 000000000..598875c11 --- /dev/null +++ b/internal/evm/gateway.go @@ -0,0 +1,99 @@ +package evm + +import ( + "fmt" + "math/big" + + gethCommon "github.com/ethereum/go-ethereum/common" + "github.com/onflow/flow-evm-gateway/bootstrap" + "github.com/onflow/flow-evm-gateway/config" + flowsdk "github.com/onflow/flow-go-sdk" + "github.com/onflow/flow-go-sdk/crypto" + "github.com/onflow/flow-go/fvm/evm/emulator" + "github.com/onflow/flowkit/v2" + "github.com/onflow/flowkit/v2/output" + "github.com/spf13/cobra" + + "github.com/onflow/flow-cli/internal/command" +) + +var Cmd = &cobra.Command{ + Use: "evm", + Short: "EVM related commands", + TraverseChildren: true, +} + +func init() { + gatewayCommand.AddToParent(Cmd) +} + +type gatewayFlag struct { + DatabaseDir string `flag:"database-dir" default:"./db" info:"path to the directory for the database"` + RPCHost string `flag:"rpc-host" default:"localhost" info:"host for the RPC API server"` + RPCPort int `flag:"rpc-port" default:"3000" info:"port for the RPC API server"` + AccessNodeGRPCHost string `flag:"access-node-grpc-host" default:"localhost:3569" info:"host to the flow access node gRPC API"` + InitHeight uint64 `flag:"init-height" default:"EmptyHeight" info:"init cadence block height from where the event ingestion will start. WARNING: you should only provide this if there are no existing values in the database, otherwise an error will be thrown"` + NetworkID string `flag:"network-id" default:"testnet" info:"EVM network ID (testnet, mainnet)"` + Coinbase string `flag:"coinbase" default:"" info:"coinbase address to use for fee collection"` + GasPrice string `flag:"gas-price" default:"1" info:"static gas price used for EVM transactions"` + COAAddress string `flag:"coa-address" default:"" info:"Flow address that holds COA account used for submitting transactions"` + COAKey string `flag:"coa-key" default:"" info:"WARNING: do not use this flag in production! private key value for the COA address used for submitting transactions"` + CreateCOAResource bool `flag:"coa-resource-create" default:"false" info:"auto-create the COA resource in the Flow COA account provided if one doesn't exist"` +} + +var flagGateway = gatewayFlag{} + +var gatewayCommand = &command.Command{ + Cmd: &cobra.Command{ + Use: "gateway", + Short: "Start the EVM gateway that exposes EVM RPC APIs", + Example: "flow evm gateway", + }, + Flags: &flagGateway, + Run: func( + args []string, + globalFlags command.GlobalFlags, + logger output.Logger, + readerWriter flowkit.ReaderWriter, + flow flowkit.Services, + ) (command.Result, error) { + cfg := &config.Config{ + DatabaseDir: flagGateway.DatabaseDir, + AccessNodeGRPCHost: flagGateway.AccessNodeGRPCHost, + RPCPort: flagGateway.RPCPort, + RPCHost: flagGateway.RPCHost, + InitHeight: flagGateway.InitHeight, + CreateCOAResource: flagGateway.CreateCOAResource, + } + + if flagGateway.Coinbase == "" { + return nil, fmt.Errorf("coinbase EVM address required") + } + cfg.Coinbase = gethCommon.HexToAddress(flagGateway.Coinbase) + if g, ok := new(big.Int).SetString(flagGateway.GasPrice, 10); ok { + cfg.GasPrice = g + } + + cfg.COAAddress = flowsdk.HexToAddress(flagGateway.COAAddress) + if cfg.COAAddress == flowsdk.EmptyAddress { + return nil, fmt.Errorf("invalid COA address value") + } + + pkey, err := crypto.DecodePrivateKeyHex(crypto.ECDSA_P256, flagGateway.COAKey) + if err != nil { + return nil, fmt.Errorf("invalid COA key: %w", err) + } + cfg.COAKey = pkey + + switch flagGateway.NetworkID { + case "testnet": + cfg.ChainID = emulator.FlowEVMTestnetChainID + case "mainnet": + cfg.ChainID = emulator.FlowEVMMainnetChainID + default: + return nil, fmt.Errorf("network ID not supported") + } + + return nil, bootstrap.Start(cfg) + }, +} From 7893414dddb2936c21c79bd7a5e1fb7dc58f9401 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 23 Feb 2024 10:07:16 -0800 Subject: [PATCH 5/9] Switch to goreleaser & add support for CGO cross-compilation (#1423) --- .github/workflows/build-release.yaml | 38 ++++++++------------ .gitignore | 5 ++- .goreleaser.yaml | 54 ++++++++++++++++++++++++++++ Makefile | 16 +++++++++ go.mod | 3 -- go.sum | 5 ++- 6 files changed, 90 insertions(+), 31 deletions(-) create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 2f57f5da8..31734c028 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -5,17 +5,9 @@ on: types: [published] jobs: - releases-matrix: + release: name: Release Go Binary runs-on: ubuntu-latest - strategy: - matrix: - # build and publish in parallel: linux/386, linux/amd64, linux/arm64, windows/386, windows/amd64, darwin/amd64, darwin/arm64 - goos: [ linux, windows, darwin ] - goarch: [ amd64, arm64 ] - exclude: - - goarch: arm64 - goos: windows steps: - uses: actions/checkout@v3 - name: Codebase security check @@ -25,19 +17,17 @@ jobs: go-version: '1.20' env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - - uses: wangyoucao577/go-release-action@v1.40 - env: - MIXPANEL_PROJECT_TOKEN: ${{ secrets.MIXPANEL_PROJECT_TOKEN }} - LILICO_TOKEN: ${{ secrets.LILICO_TOKEN }} - APP_VERSION: $(basename ${GITHUB_REF}) - BUILD_TIME: $(date --iso-8601=seconds) - VERSION: ${{github.ref_name}} - COMMIT: ${{ github.sha }} + - uses: actions/setup-go@v4 with: - pre_command: make generate - github_token: ${{ secrets.GITHUB_TOKEN }} - goos: ${{ matrix.goos }} - goarch: ${{ matrix.goarch }} - goversion: "1.20" - project_path: "./cmd/flow" - ldflags: -X "github.com/onflow/flow-cli/build.commit=${{ env.COMMIT }}" -X "github.com/onflow/flow-cli/build.semver=${{ env.VERSION }}" -X "github.com/onflow/flow-cli/internal/command.mixpanelToken=${{ env.MIXPANEL_PROJECT_TOKEN }}" -X "github.com/onflow/flow-cli/internal/accounts.accountToken=${{ env.LILICO_TOKEN }}" + go-version: "1.20" + - name: Setup Release Environment + run: |- + echo 'MIXPANEL_PROJECT_TOKEN=${{ secrets.MIXPANEL_PROJECT_TOKEN }}' > .release-env + echo 'LILICO_TOKEN=${{ secrets.LILICO_TOKEN }}' >> .release-env + echo 'APP_VERSION=$(basename ${GITHUB_REF})' >> .release-env + echo 'BUILD_TIME=$(date --iso-8601=seconds)' >> .release-env + echo 'VERSION=${{ github.ref_name }}' >> .release-env + echo 'COMMIT=${{ github.sha }}' >> .release-env + echo 'GITHUB_TOKEN=${{ secrets.FLOW_CLI_RELEASE }}' >> .release-env + - name: Build and Release + run: make release \ No newline at end of file diff --git a/.gitignore b/.gitignore index b8403f505..db38bb5af 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,7 @@ main *.pkey # Local development file generation folder -imports \ No newline at end of file +imports + +# Goreleaser .env +.release-env \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 000000000..071526d4e --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,54 @@ +before: + hooks: + - make generate + +builds: + - id: flow-cli + main: ./cmd/flow + goos: + - darwin + - linux + goarch: + - amd64 + - arm64 + env: + - CGO_FLAGS="-O2 -D__BLST_PORTABLE__" + - CGO_ENABLED=1 + - CC_darwin_amd64=o64-clang + - CXX_darwin_amd64=o64-clang+ + - CC_darwin_arm64=oa64-clang + - CXX_darwin_arm64=oa64-clang++ + - CC_linux_amd64=x86_64-linux-gnu-gcc + - CXX_linux_amd64=x86_64-linux-gnu-g++ + - CC_linux_arm64=aarch64-linux-gnu-gcc + - CXX_linux_arm64=aarch64-linux-gnu-g++ + - CC_windows_amd64=x86_64-w64-mingw32-gcc + - CXX_windows_amd64=x86_64-w64-mingw32-g++ + - CC_windows_arm64=aarch64-w64-mingw32-gcc + - CXX_windows_arm64=aarch64-w64-mingw32-g++ + - 'CC={{ index .Env (print "CC_" .Os "_" .Arch) }}' + - 'CXX={{ index .Env (print "CXX_" .Os "_" .Arch) }}' + flags: + - -mod=readonly + ldflags: + - -X github.com/onflow/flow-cli/build.commit={{ .Env.COMMIT }} -X github.com/onflow/flow-cli/build.semver={{ .Env.VERSION }} -X github.com/onflow/flow-cli/internal/command.mixpanelToken={{ .Env.MIXPANEL_PROJECT_TOKEN }} -X github.com/onflow/flow-cli/internal/accounts.accountToken={{ .Env.LILICO_TOKEN }} + +archives: + - id: golang-cross + builds: + - flow-cli + name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}-{{ .Arch }}" + format: tar.gz + wrap_in_directory: false +snapshot: + name_template: "{{ .Tag }}" +changelog: + skip: true +checksum: + name_template: "checksums.txt" +release: + github: + owner: onflow + name: flow-cli + prerelease: auto + draft: false \ No newline at end of file diff --git a/Makefile b/Makefile index 16692d4bc..a5ac84408 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +# Configuration for goreleaser +PACKAGE_NAME := github.com/onflow/flow-cli +GOLANG_CROSS_VERSION ?= v1.20.0 + # The short Git commit hash SHORT_COMMIT := $(shell git rev-parse --short HEAD) # The Git commit hash @@ -103,3 +107,15 @@ check-tidy: .PHONY: generate generate: install-tools go generate ./... + +.PHONY: release +release: + docker run \ + --rm \ + --env-file .release-env \ + -v /var/run/docker.sock:/var/run/docker.sock \ + -v `pwd`:/go/src/$(PACKAGE_NAME) \ + -v `pwd`/sysroot:/sysroot \ + -w /go/src/$(PACKAGE_NAME) \ + ghcr.io/goreleaser/goreleaser-cross:${GOLANG_CROSS_VERSION} \ + release --clean \ No newline at end of file diff --git a/go.mod b/go.mod index 892c1aa08..e271dc0ed 100644 --- a/go.mod +++ b/go.mod @@ -272,6 +272,3 @@ require ( nhooyr.io/websocket v1.8.7 // indirect rsc.io/tmplfunc v0.0.3 // indirect ) - -// this is a woraround for the flow-go/crypto cross compliation issue -replace github.com/onflow/crypto => github.com/onflow/crypto v0.24.9 diff --git a/go.sum b/go.sum index c03168fd9..cf04a239e 100644 --- a/go.sum +++ b/go.sum @@ -2068,8 +2068,8 @@ github.com/onflow/cadence-tools/test v1.0.0-M3 h1:ZbKoMhXsvafJIOO/MVE7lV5INXfq2I github.com/onflow/cadence-tools/test v1.0.0-M3/go.mod h1:Yk6OyiRMNseM6C13FpNUxTJ7GekYZMzdX5D2B10y4N8= github.com/onflow/contract-updater/lib/go/templates v1.0.1 h1:xPj898Y8OgLLbXH8+JeKVBV6J+nqPZjiLgGM3Abucto= github.com/onflow/contract-updater/lib/go/templates v1.0.1/go.mod h1:OXO6s0X7OW4Q6QTfAfnjoOmibEPgs0psOfMi+tPyzQE= -github.com/onflow/crypto v0.24.9 h1:jYP1qdwid0qCineFzBFlxBchg710A7RuSWpTqxaOdog= -github.com/onflow/crypto v0.24.9/go.mod h1:J/V7IEVaqjDajvF8K0B/SJPJDgAOP2G+LVLeb0hgmbg= +github.com/onflow/crypto v0.25.0 h1:BeWbLsh3ZD13Ej+Uky6kg1PL1ZIVBDVX+2MVBNwqddg= +github.com/onflow/crypto v0.25.0/go.mod h1:C8FbaX0x8y+FxWjbkHy0Q4EASCDR9bSPWZqlpCLYyVI= github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1 h1:IqdUzdqFCSW0klWmA3J9c17ZyQTab9SWcWSLouX6o0Q= github.com/onflow/fcl-dev-wallet v0.8.0-stable-cadence.1/go.mod h1:kc42jkiuoPJmxMRFjfbRO9XvnR/3XLheaOerxVMDTiw= github.com/onflow/flixkit-go v1.1.1-0.20240214222351-03b90f7d32ef h1:nPtuUuIMBcsl9T15qWzat8hYo6lU6ip2WKoYT2p9H4w= @@ -2359,7 +2359,6 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8= github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0= github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= -github.com/supranational/blst v0.3.10/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/supranational/blst v0.3.11 h1:LyU6FolezeWAhvQk0k6O/d49jqgO52MSDDfYgbeoEm4= github.com/supranational/blst v0.3.11/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= From 4106a71c2f483acf2f94e3f32105d54651aa2563 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Fri, 23 Feb 2024 11:08:23 -0800 Subject: [PATCH 6/9] go mod tidy --- go.mod | 18 +++++++++--------- go.sum | 25 +++++++++++++++---------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index e271dc0ed..7d8a4e0d6 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.20 require ( github.com/dukex/mixpanel v1.0.1 + github.com/ethereum/go-ethereum v1.13.5 github.com/getsentry/sentry-go v0.27.0 github.com/go-git/go-git/v5 v5.11.0 github.com/gosuri/uilive v0.0.4 @@ -17,6 +18,7 @@ require ( github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7 github.com/onflow/flow-emulator v1.0.0-M5 github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd + github.com/onflow/flow-go v0.33.2-0.20240220142056-d1573c75f26c github.com/onflow/flow-go-sdk v1.0.0-M4 github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.2.0.20240214213743-ee40994a815f github.com/onflowser/flowser/v3 v3.2.1-0.20240131200229-7d4d22715f48 @@ -29,7 +31,7 @@ require ( github.com/spf13/cobra v1.8.0 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 - golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc + golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 google.golang.org/grpc v1.61.0 ) @@ -80,7 +82,6 @@ require ( github.com/ef-ds/deque v1.0.4 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/ethereum/c-kzg-4844 v0.4.0 // indirect - github.com/ethereum/go-ethereum v1.13.5 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fxamacker/cbor/v2 v2.4.1-0.20230228173756-c0c9f774e40c // indirect github.com/fxamacker/circlehash v0.3.0 // indirect @@ -182,7 +183,6 @@ require ( github.com/onflow/crypto v0.25.0 // indirect github.com/onflow/flow-core-contracts/lib/go/contracts v0.15.2-0.20240206003101-928bf99024d7 // indirect github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 // indirect - github.com/onflow/flow-go v0.33.2-0.20240220142056-d1573c75f26c // indirect github.com/onflow/flow-nft/lib/go/contracts v1.1.1-0.20240205233530-86ee8c352fa6 // indirect github.com/onflow/flow/protobuf/go/flow v0.3.7 // indirect github.com/onflow/sdks v0.5.1-0.20230912225508-b35402f12bba // indirect @@ -244,15 +244,15 @@ require ( go.uber.org/atomic v1.11.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.24.0 // indirect - golang.org/x/crypto v0.17.0 // indirect - golang.org/x/mod v0.14.0 // indirect - golang.org/x/net v0.19.0 // indirect + golang.org/x/crypto v0.19.0 // indirect + golang.org/x/mod v0.15.0 // indirect + golang.org/x/net v0.21.0 // indirect golang.org/x/oauth2 v0.14.0 // indirect - golang.org/x/sync v0.5.0 // indirect - golang.org/x/sys v0.15.0 // indirect + golang.org/x/sync v0.6.0 // indirect + golang.org/x/sys v0.17.0 // indirect golang.org/x/text v0.14.0 // indirect golang.org/x/time v0.3.0 // indirect - golang.org/x/tools v0.16.1 // indirect + golang.org/x/tools v0.18.0 // indirect golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect gonum.org/v1/gonum v0.13.0 // indirect google.golang.org/api v0.151.0 // indirect diff --git a/go.sum b/go.sum index cf04a239e..6d3a73c8c 100644 --- a/go.sum +++ b/go.sum @@ -2535,8 +2535,8 @@ golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98y golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= -golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= -golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo= +golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -2557,8 +2557,9 @@ golang.org/x/exp v0.0.0-20220827204233-334a2380cb91/go.mod h1:cyybsKvd6eL0RnXn6p golang.org/x/exp v0.0.0-20230321023759-10a507213a29/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/exp v0.0.0-20230626212559-97b1e661b5df/go.mod h1:FXUEEKJgO7OQYeo8N01OfiKP8RXMtf6e8aTskBGqWdc= golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= -golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc h1:ao2WRsKSzW6KuUY9IWPwWahcHCgR0s52IfwutMfEbdM= golang.org/x/exp v0.0.0-20240103183307-be819d1f06fc/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225 h1:LfspQV/FYTatPTr/3HzIcmiUFH7PGP+OQ6mgDYo3yuQ= +golang.org/x/exp v0.0.0-20240222234643-814bf88cf225/go.mod h1:CxmFvTBINI24O/j8iY7H1xHzx2i4OsyguNBmN/uPtqc= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -2608,8 +2609,9 @@ golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.11.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= +golang.org/x/mod v0.15.0 h1:SernR4v+D55NyBH2QiEQrlBAnj1ECL6AGrA5+dPaMY8= +golang.org/x/mod v0.15.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -2696,8 +2698,9 @@ golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4= +golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/oauth2 v0.0.0-20170207211851-4464e7848382/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -2754,8 +2757,9 @@ golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.5.0 h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE= golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -2888,8 +2892,9 @@ golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= +golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= @@ -2906,8 +2911,8 @@ golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= -golang.org/x/term v0.15.0 h1:y/Oo/a/q3IXu26lQgl04j/gjuBDOBlx7X6Om1j2CPW4= golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= +golang.org/x/term v0.17.0 h1:mkTF7LCd6WGJNL3K1Ad7kwxNfYAW6a8a8QqtMblp/4U= 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= @@ -3024,8 +3029,8 @@ golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/tools v0.10.0/go.mod h1:UJwyiVBsOA2uwvK/e5OY3GTpDUJriEd+/YlqAwLPmyM= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= -golang.org/x/tools v0.16.1 h1:TLyB3WofjdOEepBHAU20JdNC1Zbg87elYofWYAY5oZA= -golang.org/x/tools v0.16.1/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.18.0 h1:k8NLag8AGHnn+PHbl7g43CtqZAwG60vZkLqgyZgIHgQ= +golang.org/x/tools v0.18.0/go.mod h1:GL7B4CwcLLeo59yx/9UWWuNOW1n3VZ4f5axWfML7Lcg= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 19032e533dcf2740981872893bb4566a497a123a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 28 Feb 2024 10:39:35 -0800 Subject: [PATCH 7/9] update to EVM Gateway v0.1.0 --- go.mod | 3 ++- go.sum | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 83bb3e26d..b92326fc7 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/onflow/flixkit-go v1.2.1-cadence-v1-M3 github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7 github.com/onflow/flow-emulator v1.0.0-M7 - github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd + github.com/onflow/flow-evm-gateway v0.1.0 github.com/onflow/flow-go v0.34.0-crescendo-preview.4 github.com/onflow/flow-go-sdk v1.0.0-M7 github.com/onflow/flowkit/v2 v2.0.0-stable-cadence-alpha.5.0.20240226193947-433a6c5a487d @@ -99,6 +99,7 @@ require ( github.com/go-redis/redis/v8 v8.11.5 // indirect github.com/go-stack/stack v1.8.1 // indirect github.com/gobwas/ws v1.3.0 // indirect + github.com/goccy/go-json v0.10.2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/glog v1.1.2 // indirect diff --git a/go.sum b/go.sum index 2002d954f..8519c9682 100644 --- a/go.sum +++ b/go.sum @@ -2085,8 +2085,8 @@ github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101- github.com/onflow/flow-core-contracts/lib/go/templates v0.15.2-0.20240206003101-928bf99024d7/go.mod h1:MZ2j5YVTQiSE0B99zuaYhxvGG5GcvimWpQK1Fw/1QBg= github.com/onflow/flow-emulator v1.0.0-M7 h1:8moFcl+KNAU1YOnEJim+x1pUGA5IRdfcBPgDbZkAels= github.com/onflow/flow-emulator v1.0.0-M7/go.mod h1:S611ccJDDFLC99+VIAL8slsJx5Y9rxljFCY1aS67okU= -github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd h1:qMoEHY8AfwN4Sp6kQL2rPZfEJnOBGXZyitQQmp9dEQE= -github.com/onflow/flow-evm-gateway v0.0.0-20240220202014-12947709fffd/go.mod h1:Z9bmG2qxOi8hbLAzhQHh3jFCv2fQR4dV8F7N5JL572w= +github.com/onflow/flow-evm-gateway v0.1.0 h1:UQ2cuE9eDnMjFuY40barBUvVbY9UsytEEwzOcDQpKtw= +github.com/onflow/flow-evm-gateway v0.1.0/go.mod h1:1ke+UEbmRqHqBJEp22p2kTiEt5tHYXXRdTPFTkxQqc0= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0 h1:u6/YcUvO8jU0f3Evb/6agzXqeOo+VbL2a3mmj/5ifRs= github.com/onflow/flow-ft/lib/go/contracts v0.7.1-0.20240205224107-320aa3cf09e0/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A= github.com/onflow/flow-go v0.34.0-crescendo-preview.4 h1:p0BwDm1b7qrD8roDEnPm1AeOqPU3XQr1wBXlUsoXzuU= From bf0cd0ad34c44a7a93b23cae698acb7b9b779791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 28 Feb 2024 11:05:47 -0800 Subject: [PATCH 8/9] update configuration to match gateway's config, and start to match gateway's main --- internal/evm/gateway.go | 41 +++++++++++++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 8 deletions(-) diff --git a/internal/evm/gateway.go b/internal/evm/gateway.go index 598875c11..6fedf61cf 100644 --- a/internal/evm/gateway.go +++ b/internal/evm/gateway.go @@ -1,8 +1,12 @@ package evm import ( + "context" "fmt" "math/big" + "os" + "os/signal" + "syscall" gethCommon "github.com/ethereum/go-ethereum/common" "github.com/onflow/flow-evm-gateway/bootstrap" @@ -32,8 +36,9 @@ type gatewayFlag struct { RPCHost string `flag:"rpc-host" default:"localhost" info:"host for the RPC API server"` RPCPort int `flag:"rpc-port" default:"3000" info:"port for the RPC API server"` AccessNodeGRPCHost string `flag:"access-node-grpc-host" default:"localhost:3569" info:"host to the flow access node gRPC API"` - InitHeight uint64 `flag:"init-height" default:"EmptyHeight" info:"init cadence block height from where the event ingestion will start. WARNING: you should only provide this if there are no existing values in the database, otherwise an error will be thrown"` - NetworkID string `flag:"network-id" default:"testnet" info:"EVM network ID (testnet, mainnet)"` + InitCadenceHeight uint64 `flag:"init-cadence-height" default:"0" info:"init cadence block height from where the event ingestion will start. WARNING: you should only provide this if there are no existing values in the database, otherwise an error will be thrown"` + EVMNetworkID string `flag:"evm-network-id" default:"testnet" info:"EVM network ID (testnet, mainnet)"` + FlowNetworkID string `flag:"flow-network-id" default:"emulator" info:"EVM network ID (emulator, previewnet)"` Coinbase string `flag:"coinbase" default:"" info:"coinbase address to use for fee collection"` GasPrice string `flag:"gas-price" default:"1" info:"static gas price used for EVM transactions"` COAAddress string `flag:"coa-address" default:"" info:"Flow address that holds COA account used for submitting transactions"` @@ -62,7 +67,7 @@ var gatewayCommand = &command.Command{ AccessNodeGRPCHost: flagGateway.AccessNodeGRPCHost, RPCPort: flagGateway.RPCPort, RPCHost: flagGateway.RPCHost, - InitHeight: flagGateway.InitHeight, + InitCadenceHeight: flagGateway.InitCadenceHeight, CreateCOAResource: flagGateway.CreateCOAResource, } @@ -85,15 +90,35 @@ var gatewayCommand = &command.Command{ } cfg.COAKey = pkey - switch flagGateway.NetworkID { + cfg.FlowNetworkID = flagGateway.FlowNetworkID + + switch flagGateway.EVMNetworkID { case "testnet": - cfg.ChainID = emulator.FlowEVMTestnetChainID + cfg.EVMNetworkID = emulator.FlowEVMTestnetChainID case "mainnet": - cfg.ChainID = emulator.FlowEVMMainnetChainID + cfg.EVMNetworkID = emulator.FlowEVMMainnetChainID default: - return nil, fmt.Errorf("network ID not supported") + return nil, fmt.Errorf("EVM network ID not supported") + } + + if cfg.FlowNetworkID != "previewnet" && cfg.FlowNetworkID != "emulator" { + return nil, fmt.Errorf("flow network ID is invalid, only allowed to set 'emulator' and 'previewnet'") } - return nil, bootstrap.Start(cfg) + ctx, cancel := context.WithCancel(context.Background()) + + err = bootstrap.Start(ctx, cfg) + if err != nil { + panic(err) + } + + osSig := make(chan os.Signal, 1) + signal.Notify(osSig, syscall.SIGINT, syscall.SIGTERM) + + <-osSig + fmt.Println("OS Signal to shutdown received, shutting down") + cancel() + + return nil, nil }, } From 4ad5a5a96353e3ebf679a1718c6ca8797722959a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 28 Feb 2024 11:11:29 -0800 Subject: [PATCH 9/9] add missing license header --- internal/evm/gateway.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/internal/evm/gateway.go b/internal/evm/gateway.go index 6fedf61cf..778499a89 100644 --- a/internal/evm/gateway.go +++ b/internal/evm/gateway.go @@ -1,3 +1,21 @@ +/* + * Flow CLI + * + * Copyright 2024 Flow Foundation, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package evm import (