Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the staging branch #595

Merged
merged 5 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions cmd/api/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,9 @@ type ChainConfig struct {
Name string `default:""`
ChainID tableland.ChainID `default:"0"`
Registry struct {
EthEndpoint string `default:"eth_endpoint"`
ContractAddress string `default:"contract_address"`
EthEndpoint string `default:"eth_endpoint"`
ContractAddress string `default:"contract_address"`
ProviderAuthToken string `default:"provider_auth_token"`
}
EventFeed struct {
ChainAPIBackoff string `default:"15s"`
Expand Down
12 changes: 11 additions & 1 deletion cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
ethrpc "github.com/ethereum/go-ethereum/rpc"
"github.com/google/uuid"
_ "github.com/mattn/go-sqlite3"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -185,11 +186,20 @@ func createChainIDStack(
return chains.ChainStack{}, fmt.Errorf("creating event feed store: %s", err)
}

conn, err := ethclient.Dial(config.Registry.EthEndpoint)
ethRPCClient, err := ethrpc.Dial(config.Registry.EthEndpoint)
if err != nil {
return chains.ChainStack{}, fmt.Errorf("failed to connect to ethereum endpoint: %s", err)
}

// For the Filecoin (314) chain, we need to set the auth token
// in the header of the request.
if config.ChainID == 314 && config.Registry.ProviderAuthToken != "" {
authToken := fmt.Sprintf("Bearer %s", config.Registry.ProviderAuthToken)
ethRPCClient.SetHeader("Authorization", authToken)
}

conn := ethclient.NewClient(ethRPCClient)

ef, err := efimpl.New(
eventFeedStore,
config.ChainID,
Expand Down
2 changes: 1 addition & 1 deletion docker/deployed/mainnet/api/.env_validator.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ VALIDATOR_ALCHEMY_ARBITRUM_MAINNET_API_KEY=
VALIDATOR_ALCHEMY_ETHEREUM_MAINNET_API_KEY=
VALIDATOR_ALCHEMY_POLYGON_MAINNET_API_KEY=
VALIDATOR_ALCHEMY_OPTIMISM_MAINNET_API_KEY=
VALIDATOR_ANKR_FILECOIN_MAINNET_API_KEY=
VALIDATOR_GLIF_FILECOIN_MAINNET_API_KEY=
VALIDATOR_QUICKNODE_ARBITRUM_NOVA_MAINNET_API_KEY=
METRICS_HUB_API_KEY=
8 changes: 5 additions & 3 deletions docker/deployed/mainnet/api/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,9 @@
"Name": "Filecoin Mainnet",
"ChainID": 314,
"Registry": {
"EthEndpoint": "https://rpc.ankr.com/filecoin/${VALIDATOR_ANKR_FILECOIN_MAINNET_API_KEY}",
"ContractAddress": "0x59EF8Bf2d6c102B4c42AEf9189e1a9F0ABfD652d"
"EthEndpoint": "https://node.glif.io/fvm-archive/lotus/rpc/v1",
"ContractAddress": "0x59EF8Bf2d6c102B4c42AEf9189e1a9F0ABfD652d",
"ProviderAuthToken": "${VALIDATOR_GLIF_FILECOIN_MAINNET_API_KEY}"
},
"EventFeed": {
"ChainAPIBackoff": "15s",
Expand All @@ -166,7 +167,8 @@
},
"EventProcessor": {
"BlockFailedExecutionBackoff": "10s",
"DedupExecutedTxns": true
"DedupExecutedTxns": true,
"WebhookURL": "https://discord.com/api/webhooks/${VALIDATOR_DISCORD_WEBHOOK_ID}/${VALIDATOR_DISCORD_WEBHOOK_TOKEN}"
},
"HashCalculationStep": 60
}
Expand Down
1 change: 1 addition & 0 deletions pkg/client/chains.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,4 +177,5 @@ var AnkrURLs = map[ChainID]string{
// GlifURLs contains the URLs for supported chains on Glif.
var GlifURLs = map[ChainID]string{
ChainIDs.FilecoinCalibration: "https://api.calibration.node.glif.io/rpc/v1%s",
ChainIDs.Filecoin: "https://api.node.glif.io/rpc/v1%s",
}
3 changes: 2 additions & 1 deletion pkg/eventprocessor/eventfeed/impl/eventfeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ func (ef *EventFeed) Start(
strings.Contains(err.Error(), "Log response size exceeded") ||
strings.Contains(err.Error(), "is greater than the limit") ||
strings.Contains(err.Error(), "eth_getLogs and eth_newFilter are limited to a 10,000 blocks range") ||
strings.Contains(err.Error(), "range between to and from blocks is too large") ||
strings.Contains(err.Error(), "block range is too wide") {
ef.maxBlocksFetchSize = ef.maxBlocksFetchSize * 80 / 100
} else {
Expand Down Expand Up @@ -247,7 +248,7 @@ func (ef *EventFeed) Start(
}

func (ef *EventFeed) filterLogs(ctx context.Context, query ethereum.FilterQuery) ([]types.Log, error) {
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)
ctx, cancel := context.WithTimeout(ctx, 30*time.Second)
defer cancel()
logs, err := ef.ethClient.FilterLogs(ctx, query)
if err != nil {
Expand Down
Loading