diff --git a/keeper/collections.go b/keeper/collections.go deleted file mode 100644 index 8b51247..0000000 --- a/keeper/collections.go +++ /dev/null @@ -1,40 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/vitwit/avail-da-module/types" -) - -func (k *Keeper) SetValidatorAvailAddress(ctx context.Context, validator types.Validator) error { - return k.Validators.Set(ctx, validator.ValidatorAddress, validator.AvailAddress) -} - -func (k *Keeper) GetValidatorAvailAddress(ctx context.Context, validatorAddress string) (string, error) { - return k.Validators.Get(ctx, validatorAddress) -} - -func (k *Keeper) GetAllValidators(ctx context.Context) (types.Validators, error) { - var validators types.Validators - it, err := k.Validators.Iterate(ctx, nil) - if err != nil { - return validators, err - } - - defer it.Close() - - for ; it.Valid(); it.Next() { - var validator types.Validator - validator.ValidatorAddress, err = it.Key() - if err != nil { - return validators, err - } - validator.AvailAddress, err = it.Value() - if err != nil { - return validators, err - } - validators.Validators = append(validators.Validators, validator) - } - - return validators, nil -} diff --git a/relayer/availclient.go b/relayer/availclient.go deleted file mode 100644 index 8ad7e81..0000000 --- a/relayer/availclient.go +++ /dev/null @@ -1,18 +0,0 @@ -package relayer - -// import "github.com/vitwit/avail-da-module/types" - -// // AvailClient is the client that handles data submission -// type AvailClient struct { -// config types.AvailConfiguration -// } - -// // NewAvailClient initializes a new AvailClient -// func NewAvailClient(config types.AvailConfiguration) (*AvailClient, error) { -// // api, err := gsrpc.NewSubstrateAPI(config.AppRpcURL) -// // if err != nil { -// // return nil, fmt.Errorf("cannot create api:%w", err) -// // } - -// return &AvailClient{config: config}, nil -// } diff --git a/relayer/init_test.go b/relayer/init_test.go deleted file mode 100644 index e6a0ce3..0000000 --- a/relayer/init_test.go +++ /dev/null @@ -1,61 +0,0 @@ -package relayer_test - -import ( - "testing" - - addresstypes "cosmossdk.io/core/address" - "cosmossdk.io/log" - storetypes "cosmossdk.io/store/types" - cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" - cmttime "github.com/cometbft/cometbft/types/time" - "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/codec/address" - "github.com/cosmos/cosmos-sdk/testutil" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" - sdk "github.com/cosmos/cosmos-sdk/types" - moduletestutil "github.com/cosmos/cosmos-sdk/types/module/testutil" - "github.com/stretchr/testify/suite" - module "github.com/vitwit/avail-da-module/module" - relayer "github.com/vitwit/avail-da-module/relayer" - httpclient "github.com/vitwit/avail-da-module/relayer/http" - types "github.com/vitwit/avail-da-module/types" -) - -type RelayerTestSuite struct { - suite.Suite - - ctx sdk.Context - httpHandler *httpclient.Handler - addrs []sdk.AccAddress - encCfg moduletestutil.TestEncodingConfig - addressCodec addresstypes.Codec - baseApp *baseapp.BaseApp - relayer *relayer.Relayer -} - -func TestRelayerTestSuite(t *testing.T) { - suite.Run(t, new(RelayerTestSuite)) -} - -func (s *RelayerTestSuite) SetupTest() { - key := storetypes.NewKVStoreKey(types.ModuleName) - testCtx := testutil.DefaultContextWithDB(s.T(), key, storetypes.NewTransientStoreKey("transient_test")) - s.ctx = testCtx.Ctx.WithBlockHeader(cmtproto.Header{Time: cmttime.Now()}) - s.encCfg = moduletestutil.MakeTestEncodingConfig(module.AppModuleBasic{}) - s.addressCodec = address.NewBech32Codec("cosmos") - - s.baseApp = baseapp.NewBaseApp( - "cada", - log.NewNopLogger(), - testCtx.DB, - s.encCfg.TxConfig.TxDecoder(), - ) - - s.baseApp.SetCMS(testCtx.CMS) - s.baseApp.SetInterfaceRegistry(s.encCfg.InterfaceRegistry) - s.addrs = simtestutil.CreateIncrementalAccounts(7) - - s.httpHandler = httpclient.NewHandler() - - s.relayer = &relayer.Relayer{} -} diff --git a/relayer/process.go b/relayer/process.go deleted file mode 100644 index ec8381d..0000000 --- a/relayer/process.go +++ /dev/null @@ -1,52 +0,0 @@ -package relayer - -import ( - "context" - "time" -) - -// Start begins the relayer process -func (r *Relayer) Start() error { - ctx := context.Background() - - timer := time.NewTimer(r.pollInterval) - defer timer.Stop() - for { - select { - case <-ctx.Done(): - return nil - case height := <-r.commitHeights: - r.latestCommitHeight = height - case height := <-r.provenHeights: - r.updateHeight(height) - case <-timer.C: - } - } -} - -// NotifyCommitHeight is called by the app to notify the relayer of the latest commit height -// func (r *Relayer) NotifyCommitHeight(height int64) { -// r.commitHeights <- height -// } - -// NotifyProvenHeight is called by the app to notify the relayer of the latest proven height -// i.e. the height of the highest incremental block that was proven to be posted to Avail. -// func (r *Relayer) NotifyProvenHeight(height int64) { -// r.provenHeights <- height -// } - -// updateHeight is called when the provenHeight has changed -func (r *Relayer) updateHeight(height int64) { - if height > r.latestProvenHeight { - // fmt.Println("Latest proven height:", height) // TODO: remove, debug only - r.latestProvenHeight = height - r.pruneCache(height) - } -} - -// pruneCache will delete any headers or proofs that are no longer needed -func (r *Relayer) pruneCache(_ int64) { - // r.mu.Lock() - // // TODO: proofs deletions after completion - // r.mu.Unlock() -} diff --git a/relayer/relayer.go b/relayer/relayer.go index 9fa6209..2ff494a 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -1,8 +1,6 @@ package relayer import ( - "time" - "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" @@ -15,13 +13,9 @@ import ( type Relayer struct { Logger log.Logger - provenHeights chan int64 - latestProvenHeight int64 - - commitHeights chan int64 - latestCommitHeight int64 + provenHeights chan int64 - pollInterval time.Duration + commitHeights chan int64 submittedBlocksCache map[int64]bool