Skip to content

Commit

Permalink
Merge pull request #381 from onflow/gregor/update-flow-go-block-mapping
Browse files Browse the repository at this point in the history
Update to EVM with block mapping
  • Loading branch information
sideninja authored Jul 25, 2024
2 parents 15e657a + a292bde commit 41f611d
Show file tree
Hide file tree
Showing 37 changed files with 927 additions and 689 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: CI

on:
pull_request:
branches: [main, gregor/dev]
push:
branches: [main, gregor/dev]
branches:
- "main"

jobs:
test:
Expand Down
8 changes: 4 additions & 4 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"math/big"
"strings"

evmTypes "github.com/onflow/flow-go/fvm/evm/types"
"github.com/onflow/go-ethereum/common"
"github.com/onflow/go-ethereum/common/hexutil"
"github.com/onflow/go-ethereum/common/math"
Expand Down Expand Up @@ -428,7 +427,7 @@ func (b *BlockChainAPI) GetBlockReceipts(
}

var (
block *evmTypes.Block
block *models.Block
err error
)
if numHash.BlockHash != nil {
Expand Down Expand Up @@ -856,7 +855,7 @@ func (b *BlockChainAPI) GetStorageAt(

func (b *BlockChainAPI) fetchBlockTransactions(
ctx context.Context,
block *evmTypes.Block,
block *models.Block,
) ([]*Transaction, error) {
transactions := make([]*Transaction, 0)
for _, txHash := range block.TransactionHashes {
Expand All @@ -880,10 +879,11 @@ func (b *BlockChainAPI) fetchBlockTransactions(

func (b *BlockChainAPI) prepareBlockResponse(
ctx context.Context,
block *evmTypes.Block,
block *models.Block,
fullTx bool,
) (*Block, error) {
h, err := block.Hash()
fmt.Println("### HASH", h)
if err != nil {
b.logger.Error().Err(err).Msg("failed to calculate hash for block by number")
return nil, errs.ErrInternal
Expand Down
16 changes: 4 additions & 12 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"errors"
"fmt"
"io"
"log/slog"
"net"
"net/http"
"strings"
Expand All @@ -21,6 +22,7 @@ import (
"github.com/onflow/go-ethereum/rpc"
"github.com/rs/cors"
"github.com/rs/zerolog"
slogzerolog "github.com/samber/slog-zerolog"

errs "github.com/onflow/flow-evm-gateway/api/errors"
"github.com/onflow/flow-evm-gateway/config"
Expand Down Expand Up @@ -59,18 +61,8 @@ const (
)

func NewHTTPServer(logger zerolog.Logger, cfg *config.Config) *httpServer {
gethLog.Root().SetHandler(gethLog.FuncHandler(func(r *gethLog.Record) error {
switch r.Lvl {
case gethLog.LvlInfo:
logger.Info().Msg(r.Msg)
case gethLog.LvlError:
logger.Error().Str("trace", r.Call.String()).Msg(r.Msg)
default:
logger.Debug().Msg(r.Msg)
}

return nil
}))
zeroSlog := slogzerolog.Option{Logger: &logger}.NewZerologHandler()
gethLog.SetDefault(gethLog.NewLogger(slog.New(zeroSlog).Handler()))

return &httpServer{
logger: logger,
Expand Down
6 changes: 1 addition & 5 deletions api/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"math/big"

"github.com/onflow/flow-go/fvm/evm/types"
"github.com/onflow/go-ethereum/common"
"github.com/onflow/go-ethereum/common/hexutil"
gethTypes "github.com/onflow/go-ethereum/core/types"
Expand Down Expand Up @@ -63,7 +62,7 @@ func (s *StreamAPI) NewHeads(ctx context.Context) (*rpc.Subscription, error) {
s.blocksPublisher,
func(notifier *rpc.Notifier, sub *rpc.Subscription) func(any) error {
return func(data any) error {
block, ok := data.(*types.Block)
block, ok := data.(*models.Block)
if !ok {
return fmt.Errorf("invalid data sent to block subscription")
}
Expand Down Expand Up @@ -179,9 +178,6 @@ func (s *StreamAPI) newSubscription(
case err := <-rpcSub.Err():
l.Debug().Err(err).Msg("client unsubscribed")
return
case <-notifier.Closed():
l.Debug().Msg("client unsubscribed deprecated method")
return
}
}
}()
Expand Down
8 changes: 4 additions & 4 deletions bootstrap/create-multi-key-account.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func CreateMultiKeyAccount(

pks[i] = pk
privKeys[i] = &flow.AccountKey{
Index: i,
Index: uint32(i),
PublicKey: pk.PublicKey(),
SigAlgo: crypto.ECDSA_P256,
HashAlgo: crypto.SHA3_256,
Expand Down Expand Up @@ -155,7 +155,7 @@ func CreateMultiKeyAccount(
}

var seq uint64
var index int
var index uint32
for _, k := range acc.Keys {
if k.PublicKey.Equals(key.PublicKey()) {
seq = k.SequenceNumber
Expand Down Expand Up @@ -216,7 +216,7 @@ func CreateMultiCloudKMSKeysAccount(
}

accountKeys[i] = &flow.AccountKey{
Index: i,
Index: uint32(i),
PublicKey: publicKey,
SigAlgo: crypto.ECDSA_P256,
HashAlgo: crypto.SHA2_256,
Expand Down Expand Up @@ -282,7 +282,7 @@ func CreateMultiCloudKMSKeysAccount(
}

var seq uint64
var index int
var index uint32
for _, k := range acc.Keys {
if k.PublicKey.Equals(key.PublicKey()) {
seq = k.SequenceNumber
Expand Down
54 changes: 28 additions & 26 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,23 @@ go 1.22

require (
cloud.google.com/go/storage v1.36.0
github.com/cockroachdb/pebble v0.0.0-20230928194634-aa077af62593
github.com/cockroachdb/pebble v1.1.1
github.com/goccy/go-json v0.10.2
github.com/google/uuid v1.6.0
github.com/onflow/atree v0.7.0-rc.2
github.com/onflow/cadence v1.0.0-preview.36
github.com/onflow/flow-go v0.36.0
github.com/onflow/flow-go-sdk v1.0.0-preview.38
github.com/onflow/flow/protobuf/go/flow v0.4.4
github.com/onflow/go-ethereum v1.13.4
github.com/onflow/cadence v1.0.0-preview.39
github.com/onflow/flow-go v0.36.4
github.com/onflow/flow-go-sdk v1.0.0-preview.42
github.com/onflow/flow/protobuf/go/flow v0.4.5
github.com/onflow/go-ethereum v1.14.7
github.com/rs/cors v1.8.0
github.com/rs/zerolog v1.31.0
github.com/samber/slog-zerolog v1.0.0
github.com/sethvargo/go-limiter v1.0.0
github.com/sethvargo/go-retry v0.2.3
github.com/stretchr/testify v1.9.0
golang.org/x/exp v0.0.0-20240119083558-1b970713d09a
golang.org/x/sync v0.6.0
golang.org/x/sync v0.7.0
google.golang.org/api v0.162.0
google.golang.org/grpc v1.63.2
)
Expand All @@ -31,45 +32,47 @@ require (
cloud.google.com/go/iam v1.1.6 // indirect
cloud.google.com/go/kms v1.15.7 // indirect
github.com/DataDog/zstd v1.5.2 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Microsoft/go-winio v0.6.2 // indirect
github.com/SaveTheRbtz/mph v0.1.1-0.20240117162131-4166ec7869bc // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.1 // indirect
github.com/VictoriaMetrics/fastcache v1.12.2 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.10.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.2.1 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash v1.1.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/cockroachdb/errors v1.11.3 // indirect
github.com/cockroachdb/fifo v0.0.0-20240606204812-0bbfbd93a7ce // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/redact v1.1.3 // indirect
github.com/cockroachdb/redact v1.1.5 // indirect
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
github.com/consensys/bavard v0.1.13 // indirect
github.com/consensys/gnark-crypto v0.12.1 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/crate-crypto/go-kzg-4844 v0.7.0 // indirect
github.com/crate-crypto/go-ipa v0.0.0-20240223125850-b1e8a79f509c // indirect
github.com/crate-crypto/go-kzg-4844 v1.0.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/deckarep/golang-set/v2 v2.1.0 // indirect
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/ef-ds/deque v1.0.4 // indirect
github.com/ethereum/c-kzg-4844 v0.4.0 // indirect
github.com/ethereum/c-kzg-4844 v1.0.0 // indirect
github.com/ethereum/go-ethereum v1.13.10 // indirect
github.com/ethereum/go-verkle v0.1.1-0.20240306133620-7d920df305f0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/frankban/quicktest v1.14.4 // 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
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff // indirect
github.com/getsentry/sentry-go v0.18.0 // indirect
github.com/getsentry/sentry-go v0.27.0 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-stack/stack v1.8.1 // indirect
github.com/go-ole/go-ole v1.3.0 // indirect
github.com/gofrs/flock v0.8.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/glog v1.2.0 // indirect
Expand All @@ -87,7 +90,7 @@ require (
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/holiman/bloomfilter/v2 v2.0.3 // indirect
github.com/holiman/uint256 v1.2.4 // indirect
github.com/holiman/uint256 v1.3.0 // indirect
github.com/huandu/go-clone v1.6.0 // indirect
github.com/huandu/go-clone/generic v1.7.2 // indirect
github.com/huin/goupnp v1.3.0 // indirect
Expand Down Expand Up @@ -131,8 +134,8 @@ require (
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/onflow/crypto v0.25.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/contracts v1.3.1 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.1 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.0 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.0 // indirect
github.com/onflow/flow-nft/lib/go/contracts v1.2.1 // indirect
Expand All @@ -152,6 +155,7 @@ require (
github.com/psiemens/sconfig v0.1.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/samber/lo v1.39.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/slok/go-http-metrics v0.10.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
Expand Down Expand Up @@ -189,14 +193,12 @@ require (
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.26.0 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/crypto v0.22.0 // indirect
golang.org/x/net v0.24.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gonum.org/v1/gonum v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
Loading

0 comments on commit 41f611d

Please sign in to comment.