Skip to content

Commit

Permalink
feat(claimer): WIP rework of claimer in GO
Browse files Browse the repository at this point in the history
  • Loading branch information
mpolitzer committed Oct 15, 2024
1 parent 220c32d commit 89ee448
Show file tree
Hide file tree
Showing 11 changed files with 388 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ machine-snapshot/**
/deployment.json
/anvil_state.json
/cartesi-rollups-authority-claimer
/cartesi-rollups-claimer
/cartesi-rollups-cli
/cartesi-rollups-evm-reader
/cartesi-rollups-node
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CLAIMER := cmd/authority-claimer/target/$(BUILD_TYPE)/cartesi-rollups-authority-
RUST_ARTIFACTS := $(CLAIMER)

# Go artifacts
GO_ARTIFACTS := cartesi-rollups-node cartesi-rollups-cli cartesi-rollups-evm-reader cartesi-rollups-advancer cartesi-rollups-validator
GO_ARTIFACTS := cartesi-rollups-node cartesi-rollups-cli cartesi-rollups-evm-reader cartesi-rollups-advancer cartesi-rollups-validator cartesi-rollups-claimer

# fixme(vfusco): path on all oses
CGO_CFLAGS:= -I$(PREFIX)/include
Expand Down Expand Up @@ -78,6 +78,7 @@ env:
@echo export CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER="10"
@echo export CARTESI_AUTH_MNEMONIC=\"test test test test test test test test test test test junk\"
@echo export CARTESI_POSTGRES_ENDPOINT="postgres://postgres:password@localhost:5432/rollupsdb?sslmode=disable"
@echo export CARTESI_FEATURE_CLAIMER_ENABLED=false
@echo export CARTESI_TEST_POSTGRES_ENDPOINT="postgres://test_user:password@localhost:5432/test_rollupsdb?sslmode=disable"
@echo export CARTESI_TEST_MACHINE_IMAGES_PATH=\"$(CARTESI_TEST_MACHINE_IMAGES_PATH)\"

Expand Down
18 changes: 18 additions & 0 deletions cmd/cartesi-rollups-claimer/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

package main

import (
"os"

"github.com/cartesi/rollups-node/cmd/cartesi-rollups-claimer/root"
)

func main() {
err := root.Cmd.Execute()
if err != nil {
os.Exit(1)
}
}

46 changes: 46 additions & 0 deletions cmd/cartesi-rollups-claimer/root/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// (c) Cartesi and individual authors (see AUTHORS)
// SPDX-License-Identifier: Apache-2.0 (see LICENSE)

package root

import (
"context"
"time"

"github.com/cartesi/rollups-node/internal/claimer"
"github.com/cartesi/rollups-node/internal/config"

"github.com/spf13/cobra"
)

var (
// Should be overridden during the final release build with ldflags
// to contain the actual version number
buildVersion = "devel"
)

const (
CMD_NAME = "claimer2"
)

var Cmd = &cobra.Command{
Use: CMD_NAME,
Short: "Runs Claimer",
Long: `Runs Claimer in standalone mode`,
Run: run,
}

func run(cmd *cobra.Command, args []string) {
ctx := context.Background()
c := config.FromEnv()

claimer, err := claimer.Create(&claimer.CreateInfo{
Auth: c.Auth,
BlockchainHttpEndpoint: c.BlockchainHttpEndpoint,
PostgresEndpoint: c.PostgresEndpoint,
Context: ctx,
PollInterval: 1000 * time.Millisecond,
})
cobra.CheckErr(err)
claimer.Start()
}
16 changes: 16 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ require github.com/BurntSushi/toml v1.4.0

require (
github.com/Khan/genqlient v0.7.0
github.com/aws/aws-sdk-go-v2 v1.32.2
github.com/aws/aws-sdk-go-v2/config v1.18.45
github.com/aws/aws-sdk-go-v2/service/kms v1.37.2
github.com/deepmap/oapi-codegen/v2 v2.1.0
github.com/golang-migrate/migrate/v4 v4.17.1
github.com/jackc/pgx/v5 v5.6.0
Expand All @@ -32,6 +35,16 @@ require (
github.com/alexflint/go-arg v1.4.3 // indirect
github.com/alexflint/go-scalar v1.2.0 // indirect
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.13.43 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.15.2 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 // indirect
github.com/aws/smithy-go v1.22.0 // indirect
github.com/bits-and-blooms/bitset v1.13.0 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.3.3 // indirect
github.com/consensys/bavard v0.1.13 // indirect
Expand Down Expand Up @@ -59,7 +72,9 @@ require (
github.com/invopop/yaml v0.2.0 // indirect
github.com/jackc/pgpassfile v1.0.0 // indirect
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
github.com/jackc/pgx v3.6.2+incompatible // indirect
github.com/jackc/puddle/v2 v2.2.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/klauspost/compress v1.17.9 // indirect
github.com/lib/pq v1.10.9 // indirect
Expand All @@ -70,6 +85,7 @@ require (
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 // indirect
github.com/opencontainers/image-spec v1.1.0 // indirect
github.com/perimeterx/marshmallow v1.1.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
Expand Down
40 changes: 40 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,36 @@ github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7D
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0 h1:jfIu9sQUG6Ig+0+Ap1h4unLjW6YQJpKZVmUzxsD4E/Q=
github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE=
github.com/aws/aws-sdk-go-v2 v1.21.2/go.mod h1:ErQhvNuEMhJjweavOYhxVkn2RUx7kQXVATHrjKtxIpM=
github.com/aws/aws-sdk-go-v2 v1.32.2 h1:AkNLZEyYMLnx/Q/mSKkcMqwNFXMAvFto9bNsHqcTduI=
github.com/aws/aws-sdk-go-v2 v1.32.2/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo=
github.com/aws/aws-sdk-go-v2/config v1.18.45 h1:Aka9bI7n8ysuwPeFdm77nfbyHCAKQ3z9ghB3S/38zes=
github.com/aws/aws-sdk-go-v2/config v1.18.45/go.mod h1:ZwDUgFnQgsazQTnWfeLWk5GjeqTQTL8lMkoE1UXzxdE=
github.com/aws/aws-sdk-go-v2/credentials v1.13.43 h1:LU8vo40zBlo3R7bAvBVy/ku4nxGEyZe9N8MqAeFTzF8=
github.com/aws/aws-sdk-go-v2/credentials v1.13.43/go.mod h1:zWJBz1Yf1ZtX5NGax9ZdNjhhI4rgjfgsyk6vTY1yfVg=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13 h1:PIktER+hwIG286DqXyvVENjgLTAwGgoeriLDD5C+YlQ=
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.13/go.mod h1:f/Ib/qYjhV2/qdsf79H3QP/eRE4AkVyEf6sk7XfZ1tg=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.43/go.mod h1:auo+PiyLl0n1l8A0e8RIeR8tOzYPfZZH/JNlrJ8igTQ=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 h1:UAsR3xA31QGf79WzpG/ixT9FZvQlh5HY1NRqSHBNOCk=
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21/go.mod h1:JNr43NFf5L9YaG3eKTm7HQzls9J+A9YYcGI5Quh1r2Y=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.37/go.mod h1:Qe+2KtKml+FEsQF/DHmDV+xjtche/hwoF75EG4UlHW8=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 h1:6jZVETqmYCadGFvrYEQfC5fAQmlo80CeL5psbno6r0s=
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21/go.mod h1:1SR0GbLlnN3QUmYaflZNiH1ql+1qrSiB2vwcJ+4UM60=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45 h1:hze8YsjSh8Wl1rYa1CJpRmXP21BvOBuc76YhW0HsuQ4=
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.45/go.mod h1:lD5M20o09/LCuQ2mE62Mb/iSdSlCNuj6H5ci7tW7OsE=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37 h1:WWZA/I2K4ptBS1kg0kV1JbBtG/umed0vwHRrmcr9z7k=
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.37/go.mod h1:vBmDnwWXWxNPFRMmG2m/3MKOe+xEcMDo1tanpaWCcck=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.2 h1:tfBABi5R6aSZlhgTWHxL+opYUDOnIGoNcJLwVYv0jLM=
github.com/aws/aws-sdk-go-v2/service/kms v1.37.2/go.mod h1:dZYFcQwuoh+cLOlFnZItijZptmyDhRIkOKWFO1CfzV8=
github.com/aws/aws-sdk-go-v2/service/sso v1.15.2 h1:JuPGc7IkOP4AaqcZSIcyqLpFSqBWK32rM9+a1g6u73k=
github.com/aws/aws-sdk-go-v2/service/sso v1.15.2/go.mod h1:gsL4keucRCgW+xA85ALBpRFfdSLH4kHOVSnLMSuBECo=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3 h1:HFiiRkf1SdaAmV3/BHOFZ9DjFynPHj8G/UIO1lQS+fk=
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.17.3/go.mod h1:a7bHA82fyUXOm+ZSWKU6PIoBxrjSprdLoM8xPYvzYVg=
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2 h1:0BkLfgeDjfZnZ+MhB3ONb01u9pwFYTCZVhlsSSBvlbU=
github.com/aws/aws-sdk-go-v2/service/sts v1.23.2/go.mod h1:Eows6e1uQEsc4ZaHANmsPRzAKcVDrcmjjWiih2+HUUQ=
github.com/aws/smithy-go v1.15.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA=
github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM=
github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
Expand Down Expand Up @@ -134,6 +164,9 @@ github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk=
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
Expand Down Expand Up @@ -164,12 +197,18 @@ github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsI
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
github.com/jackc/pgx v3.6.2+incompatible h1:2zP5OD7kiyR3xzRYMhOcXVvkDZsImVXfj+yIyTQf3/o=
github.com/jackc/pgx v3.6.2+incompatible/go.mod h1:0ZGrqGqkRlliWnWB4zKnWtjbSWbGkVEFm4TeybAXq+I=
github.com/jackc/pgx/v5 v5.6.0 h1:SWJzexBzPL5jb0GEsrPMLIsi/3jOo7RHlzTjcAeDrPY=
github.com/jackc/pgx/v5 v5.6.0/go.mod h1:DNZ/vlrUnhWCoFGxHAG8U2ljioxukquj7utPDgtQdTw=
github.com/jackc/puddle/v2 v2.2.1 h1:RhxXJtFG022u4ibrCSMSiu5aOq1i77R3OHKNJj77OAk=
github.com/jackc/puddle/v2 v2.2.1/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
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/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/juju/gnuflag v0.0.0-20171113085948-2ce1bb71843d/go.mod h1:2PavIy+JPciBPrBUjwbNvtwB6RQlve+hkpll6QSNmOE=
Expand Down Expand Up @@ -330,6 +369,7 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Expand Down
140 changes: 140 additions & 0 deletions internal/claimer/service.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
package claimer

import (
"context"
"fmt"
"log/slog"
"math/big"
"time"

signtx "github.com/cartesi/rollups-node/internal/aws-kms-signtx"
conf "github.com/cartesi/rollups-node/internal/config"
repo "github.com/cartesi/rollups-node/internal/repository"
"github.com/cartesi/rollups-node/pkg/contracts/iconsensus"
"github.com/cartesi/rollups-node/pkg/ethutil"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethclient"

"github.com/aws/aws-sdk-go-v2/aws"
aws_cfg "github.com/aws/aws-sdk-go-v2/config"
aws_kms "github.com/aws/aws-sdk-go-v2/service/kms"
)

type CreateInfo struct {
Auth conf.Auth
BlockchainHttpEndpoint conf.Redacted[string]
Context context.Context
EthConn ethclient.Client
PollInterval time.Duration
PostgresEndpoint conf.Redacted[string]
}

type Service struct {
consensus iconsensus.IConsensus
context context.Context
dbConn *repo.Database
ethConn *ethclient.Client
signer *bind.TransactOpts
ticker *time.Ticker
}

func createSigner(ctx context.Context, auth conf.Auth, chainID *big.Int) (*bind.TransactOpts, error) {
switch auth := auth.(type) {
case conf.AuthMnemonic:
privateKey, err := ethutil.MnemonicToPrivateKey(
auth.Mnemonic.Value, uint32(auth.AccountIndex.Value))
if err != nil {
return nil, err
}
return bind.NewKeyedTransactorWithChainID(privateKey, chainID)
case conf.AuthAWS:
awsc, err := aws_cfg.LoadDefaultConfig(ctx)
if err != nil {
return nil, err
}
kms := aws_kms.NewFromConfig(awsc, func(o *aws_kms.Options) {
o.BaseEndpoint = aws.String(auth.EndpointURL.Value)
})
return signtx.CreateAWSTransactOpts(ctx, kms,
aws.String(auth.KeyID.Value), types.NewEIP155Signer(chainID))
}
return nil, fmt.Errorf("error: unimplemented authentication method")
}

func Create(ci *CreateInfo) (s *Service, err error) {
ethconn, err := ethclient.Dial(ci.BlockchainHttpEndpoint.Value)
if err != nil {
return nil, err
}

chainid, err := ethconn.NetworkID(ci.Context)
if err != nil {
return nil, err
}

signer, err := createSigner(ci.Context, ci.Auth, chainid)
if err != nil {
return nil, err
}

dbconn, err := repo.Connect(ci.Context, ci.PostgresEndpoint.Value)
if err != nil {
return nil, err
}

return &Service{
context: ci.Context,
dbConn: dbconn,
ethConn: ethconn,
signer: signer,
ticker: time.NewTicker(ci.PollInterval),
}, nil
}

func (s *Service) onTick() error {
claims, err := s.dbConn.GetComputedClaims(s.context)
if err != nil {
return err
}

slog.Info("claimer: polling database for computed claims:", "found", len(claims))
for _, claim := range(claims) {
// TODO: detect duplicates?

slog.Info("claimer: submitting:", "claim", claim)
instance, err := iconsensus.NewIConsensus(claim.IConsensusAddress, s.ethConn)
if err != nil {
return err
}

tx, err := instance.SubmitClaim(s.signer, claim.AppAddress, claim.LastBlock, claim.Hash)
if err != nil {
return err
}

slog.Info("claimer: got receipt", "transaction_hash", tx.Hash())
err = s.dbConn.SetClaimAsSubmitted(s.context, claim.ID, tx.Hash())
if err != nil {
return err
}
}
return nil
}

// TODO: implement quit channel
func (s *Service) Start() error {
for {
select {
case <-s.ticker.C:
err := s.onTick()
if err != nil {
slog.Error("failed: ", "cause", err)
}
// TODO: recreate DBConn on error
// TODO: recreate EthConn on error
_ = err
}
}
}
10 changes: 6 additions & 4 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ type AuthMnemonic struct {

// AuthAWS allows signing through AWS services.
type AuthAWS struct {
KeyID Redacted[string]
Region Redacted[string]
KeyID Redacted[string]
Region Redacted[string]
EndpointURL Redacted[string]
}

// Redacted is a wrapper that redacts a given field from the logs.
Expand Down Expand Up @@ -146,8 +147,9 @@ func authFromEnv() Auth {
}
case AuthKindAWS:
return AuthAWS{
KeyID: Redacted[string]{GetAuthAwsKmsKeyId()},
Region: Redacted[string]{GetAuthAwsKmsRegion()},
KeyID: Redacted[string]{GetAuthAwsKmsKeyId()},
Region: Redacted[string]{GetAuthAwsKmsRegion()},
EndpointURL: Redacted[string]{GetAuthAwsEndpointUrl()},
}
default:
panic("invalid auth kind")
Expand Down
5 changes: 5 additions & 0 deletions internal/config/generate/Config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ An AWS KMS Region.
Must be set alongside `CARTESI_AUTH_AWS_KMS_KEY_ID`."""

[auth.CARTESI_AUTH_AWS_ENDPOINT_URL]
go-type = "string"
description = """
An AWS Endpoint URL."""

#
# Postgres
#
Expand Down
Loading

0 comments on commit 89ee448

Please sign in to comment.