diff --git a/relayer/availclient.go b/relayer/availclient.go index d4695d0..8ad7e81 100644 --- a/relayer/availclient.go +++ b/relayer/availclient.go @@ -1,18 +1,18 @@ package relayer -import "github.com/vitwit/avail-da-module/types" +// import "github.com/vitwit/avail-da-module/types" -// AvailClient is the client that handles data submission -type AvailClient struct { - config types.AvailConfiguration -} +// // 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) - // } +// // 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 -} +// return &AvailClient{config: config}, nil +// } diff --git a/relayer/client.go b/relayer/client.go index 95fa9ab..af26f6b 100644 --- a/relayer/client.go +++ b/relayer/client.go @@ -1,151 +1,151 @@ package relayer -import ( - "fmt" - - cometrpc "github.com/cometbft/cometbft/rpc/client/http" - "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/cosmos/cosmos-sdk/client/tx" - "github.com/cosmos/cosmos-sdk/codec" - codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keyring" - "github.com/cosmos/cosmos-sdk/std" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/module" - "github.com/cosmos/cosmos-sdk/types/tx/signing" - authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" - authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - "github.com/cosmos/go-bip39" -) - -const ( - defaultGasAdjustment = 1.0 - defaultGasLimit = 300000 -) - -// var availdHomePath = xfilepath.JoinFromHome(xfilepath.Path("availsdk")) - -func NewClientCtx(kr keyring.Keyring, c *cometrpc.HTTP, chainID string, - cdc codec.BinaryCodec, homepath string, fromAddress sdk.AccAddress, -) client.Context { - encodingConfig := MakeEncodingConfig() - - broadcastMode := flags.BroadcastSync - - return client.Context{}. - WithCodec(cdc.(codec.Codec)). - WithChainID(chainID). - WithFromAddress(fromAddress). - WithFromName("testkey"). - WithKeyringDir(homepath). - WithBroadcastMode(broadcastMode). - WithTxConfig(authTx.NewTxConfig(cdc.(codec.Codec), authTx.DefaultSignModes)). - WithKeyring(kr). - WithAccountRetriever(authtypes.AccountRetriever{}). - WithClient(c).WithInterfaceRegistry(encodingConfig.InterfaceRegistry). - WithSkipConfirmation(true) -} - -// NewFactory creates a new Factory. -func NewFactory(clientCtx client.Context) tx.Factory { - return tx.Factory{}. - WithChainID(clientCtx.ChainID). - WithKeybase(clientCtx.Keyring). - WithGas(defaultGasLimit). - WithGasAdjustment(defaultGasAdjustment). - WithSignMode(signing.SignMode_SIGN_MODE_DIRECT). - WithAccountRetriever(clientCtx.AccountRetriever). - WithTxConfig(clientCtx.TxConfig) -} - -// MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. -func MakeEncodingConfig(modules ...module.AppModuleBasic) EncodingConfig { - aminoCodec := codec.NewLegacyAmino() - interfaceRegistry := codectypes.NewInterfaceRegistry() - codec := codec.NewProtoCodec(interfaceRegistry) - txCfg := authTx.NewTxConfig(codec, authTx.DefaultSignModes) - - encCfg := EncodingConfig{ - InterfaceRegistry: interfaceRegistry, - Codec: codec, - TxConfig: txCfg, - Amino: aminoCodec, - } - - mb := module.NewBasicManager(modules...) - - std.RegisterLegacyAminoCodec(encCfg.Amino) - std.RegisterInterfaces(encCfg.InterfaceRegistry) - mb.RegisterLegacyAminoCodec(encCfg.Amino) - mb.RegisterInterfaces(encCfg.InterfaceRegistry) - - return encCfg -} - -// EncodingConfig specifies the concrete encoding types to use for a given app. -// This is provided for compatibility between protobuf and amino implementations. -type EncodingConfig struct { - InterfaceRegistry codectypes.InterfaceRegistry - Codec codec.Codec - TxConfig client.TxConfig - Amino *codec.LegacyAmino -} - -// ImportMnemonic is to import existing account mnemonic in keyring -func ImportMnemonic(keyName, mnemonic, hdPath string, c client.Context) (*keyring.Record, error) { - info, err := AccountCreate(keyName, mnemonic, hdPath, c) // return account also - if err != nil { - return nil, err - } - - return info, nil -} - -// AccountCreate creates an account by name and mnemonic (optional) in the keyring. -func AccountCreate(accountName, mnemonic, _ string, c client.Context) (*keyring.Record, error) { - if mnemonic == "" { - entropySeed, err := bip39.NewEntropy(256) - if err != nil { - return nil, err - } - mnemonic, err = bip39.NewMnemonic(entropySeed) - if err != nil { - return nil, err - } - } - - algos, _ := c.Keyring.SupportedAlgorithms() - algo, err := keyring.NewSigningAlgoFromString(string(hd.Secp256k1Type), algos) - if err != nil { - return nil, err - } - - path := hd.CreateHDPath(118, 0, 0).String() - // fmt.Println("pathhh......", path) - - // record, str, err := c.Keyring.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) - // fmt.Println("recorddddd.......", err, str, record) - - // k, _, err = kb.NewMnemonic("test", English, types.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) - info, err := c.Keyring.NewAccount(accountName, mnemonic, keyring.DefaultBIP39Passphrase, path, algo) - fmt.Println("after creationnnn.........", info, err) - if err != nil { - return nil, err - } - // pk, err := info.GetPubKey() - // if err != nil { - // return nil, err - // } - - // addr := sdk.AccAddress(pk.Address()) - // fmt.Println("address hereee...", addr) - - // aa, err := info.GetAddress() - // fmt.Println("here aa and err.......", aa, err) - - // account := c.ToAccount(info) - // account.Mnemonic = mnemonic - return info, nil -} +// import ( +// "fmt" + +// cometrpc "github.com/cometbft/cometbft/rpc/client/http" +// "github.com/cosmos/cosmos-sdk/client" +// "github.com/cosmos/cosmos-sdk/client/flags" +// "github.com/cosmos/cosmos-sdk/client/tx" +// "github.com/cosmos/cosmos-sdk/codec" +// codectypes "github.com/cosmos/cosmos-sdk/codec/types" +// "github.com/cosmos/cosmos-sdk/crypto/hd" +// "github.com/cosmos/cosmos-sdk/crypto/keyring" +// "github.com/cosmos/cosmos-sdk/std" +// sdk "github.com/cosmos/cosmos-sdk/types" +// "github.com/cosmos/cosmos-sdk/types/module" +// "github.com/cosmos/cosmos-sdk/types/tx/signing" +// authTx "github.com/cosmos/cosmos-sdk/x/auth/tx" +// authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" +// "github.com/cosmos/go-bip39" +// ) + +// const ( +// defaultGasAdjustment = 1.0 +// defaultGasLimit = 300000 +// ) + +// // var availdHomePath = xfilepath.JoinFromHome(xfilepath.Path("availsdk")) + +// func NewClientCtx(kr keyring.Keyring, c *cometrpc.HTTP, chainID string, +// cdc codec.BinaryCodec, homepath string, fromAddress sdk.AccAddress, +// ) client.Context { +// encodingConfig := MakeEncodingConfig() + +// broadcastMode := flags.BroadcastSync + +// return client.Context{}. +// WithCodec(cdc.(codec.Codec)). +// WithChainID(chainID). +// WithFromAddress(fromAddress). +// WithFromName("testkey"). +// WithKeyringDir(homepath). +// WithBroadcastMode(broadcastMode). +// WithTxConfig(authTx.NewTxConfig(cdc.(codec.Codec), authTx.DefaultSignModes)). +// WithKeyring(kr). +// WithAccountRetriever(authtypes.AccountRetriever{}). +// WithClient(c).WithInterfaceRegistry(encodingConfig.InterfaceRegistry). +// WithSkipConfirmation(true) +// } + +// // NewFactory creates a new Factory. +// func NewFactory(clientCtx client.Context) tx.Factory { +// return tx.Factory{}. +// WithChainID(clientCtx.ChainID). +// WithKeybase(clientCtx.Keyring). +// WithGas(defaultGasLimit). +// WithGasAdjustment(defaultGasAdjustment). +// WithSignMode(signing.SignMode_SIGN_MODE_DIRECT). +// WithAccountRetriever(clientCtx.AccountRetriever). +// WithTxConfig(clientCtx.TxConfig) +// } + +// // MakeEncodingConfig creates an EncodingConfig for an amino based test configuration. +// func MakeEncodingConfig(modules ...module.AppModuleBasic) EncodingConfig { +// aminoCodec := codec.NewLegacyAmino() +// interfaceRegistry := codectypes.NewInterfaceRegistry() +// codec := codec.NewProtoCodec(interfaceRegistry) +// txCfg := authTx.NewTxConfig(codec, authTx.DefaultSignModes) + +// encCfg := EncodingConfig{ +// InterfaceRegistry: interfaceRegistry, +// Codec: codec, +// TxConfig: txCfg, +// Amino: aminoCodec, +// } + +// mb := module.NewBasicManager(modules...) + +// std.RegisterLegacyAminoCodec(encCfg.Amino) +// std.RegisterInterfaces(encCfg.InterfaceRegistry) +// mb.RegisterLegacyAminoCodec(encCfg.Amino) +// mb.RegisterInterfaces(encCfg.InterfaceRegistry) + +// return encCfg +// } + +// // EncodingConfig specifies the concrete encoding types to use for a given app. +// // This is provided for compatibility between protobuf and amino implementations. +// type EncodingConfig struct { +// InterfaceRegistry codectypes.InterfaceRegistry +// Codec codec.Codec +// TxConfig client.TxConfig +// Amino *codec.LegacyAmino +// } + +// // ImportMnemonic is to import existing account mnemonic in keyring +// func ImportMnemonic(keyName, mnemonic, hdPath string, c client.Context) (*keyring.Record, error) { +// info, err := AccountCreate(keyName, mnemonic, hdPath, c) // return account also +// if err != nil { +// return nil, err +// } + +// return info, nil +// } + +// // AccountCreate creates an account by name and mnemonic (optional) in the keyring. +// func AccountCreate(accountName, mnemonic, _ string, c client.Context) (*keyring.Record, error) { +// if mnemonic == "" { +// entropySeed, err := bip39.NewEntropy(256) +// if err != nil { +// return nil, err +// } +// mnemonic, err = bip39.NewMnemonic(entropySeed) +// if err != nil { +// return nil, err +// } +// } + +// algos, _ := c.Keyring.SupportedAlgorithms() +// algo, err := keyring.NewSigningAlgoFromString(string(hd.Secp256k1Type), algos) +// if err != nil { +// return nil, err +// } + +// path := hd.CreateHDPath(118, 0, 0).String() +// // fmt.Println("pathhh......", path) + +// // record, str, err := c.Keyring.NewMnemonic("test_key1", keyring.English, path, keyring.DefaultBIP39Passphrase, hd.Secp256k1) +// // fmt.Println("recorddddd.......", err, str, record) + +// // k, _, err = kb.NewMnemonic("test", English, types.FullFundraiserPath, DefaultBIP39Passphrase, hd.Secp256k1) +// info, err := c.Keyring.NewAccount(accountName, mnemonic, keyring.DefaultBIP39Passphrase, path, algo) +// fmt.Println("after creationnnn.........", info, err) +// if err != nil { +// return nil, err +// } +// // pk, err := info.GetPubKey() +// // if err != nil { +// // return nil, err +// // } + +// // addr := sdk.AccAddress(pk.Address()) +// // fmt.Println("address hereee...", addr) + +// // aa, err := info.GetAddress() +// // fmt.Println("here aa and err.......", aa, err) + +// // account := c.ToAccount(info) +// // account.Mnemonic = mnemonic +// return info, nil +// } diff --git a/relayer/local/cosmosprovider.go b/relayer/local/cosmos_provider.go similarity index 100% rename from relayer/local/cosmosprovider.go rename to relayer/local/cosmos_provider.go diff --git a/relayer/process.go b/relayer/process.go index 914d8ae..ec8381d 100644 --- a/relayer/process.go +++ b/relayer/process.go @@ -20,21 +20,20 @@ func (r *Relayer) Start() error { case height := <-r.provenHeights: r.updateHeight(height) case <-timer.C: - // TODO: client update } } } // NotifyCommitHeight is called by the app to notify the relayer of the latest commit height -func (r *Relayer) NotifyCommitHeight(height int64) { - r.commitHeights <- 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 -} +// func (r *Relayer) NotifyProvenHeight(height int64) { +// r.provenHeights <- height +// } // updateHeight is called when the provenHeight has changed func (r *Relayer) updateHeight(height int64) { diff --git a/relayer/publish.go b/relayer/publish.go index ada0da0..8789355 100644 --- a/relayer/publish.go +++ b/relayer/publish.go @@ -10,28 +10,28 @@ import ( "github.com/vitwit/avail-da-module/types" ) -func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []int64 { - height := ctx.BlockHeight() - - if height <= 1 { - return nil - } - - // only publish new blocks on interval - if (height-1)%int64(r.AvailConfig.PublishBlobInterval) != 0 { - return nil - } - - var blocks []int64 - for block := height - int64(r.AvailConfig.PublishBlobInterval); block < height; block++ { - // this could be false after a genesis restart - if block > provenHeight { - blocks = append(blocks, block) - } - } - - return blocks -} +// func (r *Relayer) ProposePostNextBlocks(ctx sdk.Context, provenHeight int64) []int64 { +// height := ctx.BlockHeight() + +// if height <= 1 { +// return nil +// } + +// // only publish new blocks on interval +// if (height-1)%int64(r.AvailConfig.PublishBlobInterval) != 0 { +// return nil +// } + +// var blocks []int64 +// for block := height - int64(r.AvailConfig.PublishBlobInterval); block < height; block++ { +// // this could be false after a genesis restart +// if block > provenHeight { +// blocks = append(blocks, block) +// } +// } + +// return blocks +// } // PostBlocks is called in the PreBlocker. The proposer will publish the blocks at this point // once their block has been accepted. The method launches the posting process in a separate diff --git a/relayer/relayer.go b/relayer/relayer.go index a5e7422..9ef7021 100644 --- a/relayer/relayer.go +++ b/relayer/relayer.go @@ -11,10 +11,10 @@ import ( "github.com/vitwit/avail-da-module/types" ) -const ( - DefaultMaxFlushSize = int(20) - MaxMaxFlushSize = int(100) -) +// const ( +// DefaultMaxFlushSize = int(20) +// MaxMaxFlushSize = int(100) +// ) // Relayer is responsible for posting new blocks to Avail type Relayer struct { diff --git a/simapp/app/app.go b/simapp/app/app.go index f268922..525fc1a 100644 --- a/simapp/app/app.go +++ b/simapp/app/app.go @@ -1018,7 +1018,7 @@ func (app *ChainApp) FinalizeBlock(req *abci.RequestFinalizeBlock) (*abci.Respon } //app.Availblobrelayer.NotifyCommitHeight(req.Height) - app.Availblobrelayer.NotifyCommitHeight(req.Height) + // app.Availblobrelayer.NotifyCommitHeight(req.Height) return res, nil } @@ -1224,9 +1224,9 @@ func (app *ChainApp) RegisterTendermintService(clientCtx client.Context) { func (app *ChainApp) RegisterNodeService(clientCtx client.Context, cfg config.Config) { nodeservice.RegisterNodeService(clientCtx, app.GRPCQueryRouter(), cfg) - app.Availblobrelayer.SetClientContext(clientCtx) + // app.Availblobrelayer.SetClientContext(clientCtx) - go app.Availblobrelayer.Start() + // go app.Availblobrelayer.Start() } // GetMaccPerms returns a copy of the module account permissions diff --git a/types/avail_config.go b/types/avail_config.go index 897af29..21b5b72 100644 --- a/types/avail_config.go +++ b/types/avail_config.go @@ -89,7 +89,7 @@ var DefaultAvailConfig = AvailConfiguration{ VoteInterval: 5, LightClientURL: "http://127.0.0.1:8000", ValidatorKey: "alice", - // CosmosNodeDir: ".availsdk", + // CosmosNodeDir: ".simapp", } func AvailConfigFromAppOpts(appOpts servertypes.AppOptions) AvailConfiguration { diff --git a/types/codec.go b/types/codec.go index 8050079..09b8858 100644 --- a/types/codec.go +++ b/types/codec.go @@ -11,7 +11,7 @@ import ( // RegisterLegacyAminoCodec registers the necessary interfaces and concrete types // on the provided LegacyAmino codec. These types are used for Amino JSON serialization. func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { - legacy.RegisterAminoMsg(cdc, &MsgUpdateBlobStatusRequest{}, "availblob/MsgUpdateBlobStatusRequest") + legacy.RegisterAminoMsg(cdc, &MsgUpdateBlobStatusRequest{}, "cada/MsgUpdateBlobStatusRequest") } // RegisterInterfaces registers the interfaces types with the interface registry. diff --git a/types/validation.go b/types/validation.go deleted file mode 100644 index ab1254f..0000000 --- a/types/validation.go +++ /dev/null @@ -1 +0,0 @@ -package types