mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-26 00:05:18 +00:00
Merge pull request #28 from 0glabs/dev
testnet: merge dev for relaunch version
This commit is contained in:
commit
b37e27e58b
4
.gitignore
vendored
4
.gitignore
vendored
@ -42,3 +42,7 @@ build/linux
|
||||
go.work
|
||||
go.work.sum
|
||||
.build/0gchaind
|
||||
.build/da
|
||||
|
||||
# runtime
|
||||
run
|
||||
|
2
Makefile
2
Makefile
@ -78,7 +78,7 @@ print-machine-info:
|
||||
BUILD_DIR := build# build files
|
||||
BIN_DIR := $(BUILD_DIR)/bin# for binary dev dependencies
|
||||
BUILD_CACHE_DIR := $(BUILD_DIR)/.cache# caching for non-artifact outputs
|
||||
OUT_DIR := out# for artifact intermediates and outputs
|
||||
OUT_DIR := ./.build# for artifact intermediates and outputs
|
||||
|
||||
ROOT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))# absolute path to root
|
||||
export PATH := $(ROOT_DIR)/$(BIN_DIR):$(PATH)# add local bin first in path
|
||||
|
@ -8,8 +8,8 @@ import (
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/client/context"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -62,11 +62,11 @@ func (suite *SimulateRequestTestSuite) TestSimulateRequest() {
|
||||
bank.MsgSend{
|
||||
FromAddress: fromAddr,
|
||||
ToAddress: toAddr,
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e6)),
|
||||
},
|
||||
},
|
||||
Fee: auth.StdFee{
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(5e4))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(5e4)),
|
||||
Gas: 1e6,
|
||||
},
|
||||
Memo: "test memo",
|
||||
|
@ -66,7 +66,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
chainID,
|
||||
app.NewFundedGenStateWithSameCoins(
|
||||
tApp.AppCodec(),
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 1e9)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
|
||||
testAddresses,
|
||||
),
|
||||
newBep3GenStateMulti(tApp.AppCodec(), deputy),
|
||||
@ -114,7 +114,7 @@ func TestAppAnteHandler_AuthorizedMempool(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
tc.address,
|
||||
testAddresses[0],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 1_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1_000_000)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
var _ sdk.AnteHandler = (&MockAnteHandler{}).AnteHandle
|
||||
@ -45,7 +46,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_NotCheckTx(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100_000_000)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100_000_000)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
@ -80,12 +81,12 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Pass(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[2],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
@ -121,7 +122,7 @@ func TestAuthenticatedMempoolDecorator_AnteHandle_Reject(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
},
|
||||
sdk.NewCoins(), // no fee
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
func newMsgGrant(granter sdk.AccAddress, grantee sdk.AccAddress, a authz.Authorization, expiration time.Time) *authz.MsgGrant {
|
||||
@ -58,7 +59,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
),
|
||||
},
|
||||
checkTx: false,
|
||||
@ -128,7 +129,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
[]sdk.Msg{banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[3],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
)}),
|
||||
},
|
||||
checkTx: false,
|
||||
@ -161,7 +162,7 @@ func TestAuthzLimiterDecorator(t *testing.T) {
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0],
|
||||
testAddresses[3],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100e6)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100e6)),
|
||||
),
|
||||
&evmtypes.MsgEthereumTx{},
|
||||
},
|
||||
|
@ -34,6 +34,7 @@ import (
|
||||
"github.com/tendermint/tendermint/version"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper"
|
||||
evmutiltestutil "github.com/0glabs/0g-chain/x/evmutil/testutil"
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
@ -155,7 +156,7 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
// Genesis states
|
||||
evmGs := evmtypes.NewGenesisState(
|
||||
evmtypes.NewParams(
|
||||
"neuron", // evmDenom
|
||||
chaincfg.EvmDenom, // evmDenom
|
||||
false, // allowedUnprotectedTxs
|
||||
true, // enableCreate
|
||||
true, // enableCall
|
||||
@ -221,10 +222,10 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
pricefeedtypes.ModuleName: cdc.MustMarshalJSON(&pricefeedGenState),
|
||||
}
|
||||
|
||||
// funds our test accounts with some ua0gi
|
||||
// funds our test accounts with some gas denom
|
||||
coinsGenState := app.NewFundedGenStateWithSameCoins(
|
||||
tApp.AppCodec(),
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 1e9)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e9)),
|
||||
[]sdk.AccAddress{suite.testAddr, suite.testAddr2},
|
||||
)
|
||||
|
||||
@ -306,17 +307,17 @@ func (suite *EIP712TestSuite) SetupTest() {
|
||||
params := evmKeeper.GetParams(suite.ctx)
|
||||
params.EIP712AllowedMsgs = []evmtypes.EIP712AllowedMsg{
|
||||
{
|
||||
MsgTypeUrl: "/0g-chain.evmutil.v1beta1.MsgConvertERC20ToCoin",
|
||||
MsgTypeUrl: "/zgc.evmutil.v1beta1.MsgConvertERC20ToCoin",
|
||||
MsgValueTypeName: "MsgValueEVMConvertERC20ToCoin",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "initiator", Type: "string"},
|
||||
{Name: "receiver", Type: "string"},
|
||||
{Name: "0gchain_erc20_address", Type: "string"},
|
||||
{Name: "zgchain_erc20_address", Type: "string"},
|
||||
{Name: "amount", Type: "string"},
|
||||
},
|
||||
},
|
||||
{
|
||||
MsgTypeUrl: "/0g-chain.evmutil.v1beta1.MsgConvertCoinToERC20",
|
||||
MsgTypeUrl: "/zgc.evmutil.v1beta1.MsgConvertCoinToERC20",
|
||||
MsgValueTypeName: "MsgValueEVMConvertCoinToERC20",
|
||||
ValueTypes: []evmtypes.EIP712MsgAttrType{
|
||||
{Name: "initiator", Type: "string"},
|
||||
@ -369,7 +370,7 @@ func (suite *EIP712TestSuite) deployUSDCERC20(app app.TestApp, ctx sdk.Context)
|
||||
suite.tApp.FundModuleAccount(
|
||||
suite.ctx,
|
||||
evmutiltypes.ModuleName,
|
||||
sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(0))),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(0)),
|
||||
)
|
||||
|
||||
contractAddr, err := suite.evmutilKeeper.DeployTestMintableERC20Contract(suite.ctx, "USDC", "USDC", uint8(18))
|
||||
@ -469,7 +470,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
errMsg: "insufficient funds",
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
bk := suite.tApp.GetBankKeeper()
|
||||
gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, "ua0gi")
|
||||
gasCoins := bk.GetBalance(suite.ctx, suite.testAddr, chaincfg.GasDenom)
|
||||
suite.tApp.GetBankKeeper().SendCoins(suite.ctx, suite.testAddr, suite.testAddr2, sdk.NewCoins(gasCoins))
|
||||
return txBuilder
|
||||
},
|
||||
@ -481,7 +482,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
failCheckTx: true,
|
||||
errMsg: "invalid chain-id",
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
return suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, "kavatest_12-1", uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -494,7 +495,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
failCheckTx: true,
|
||||
errMsg: "invalid pubkey",
|
||||
updateTx: func(txBuilder client.TxBuilder, msgs []sdk.Msg) client.TxBuilder {
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
return suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr2, suite.testPrivKey2, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -522,7 +523,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx() {
|
||||
msgs = tc.updateMsgs(msgs)
|
||||
}
|
||||
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, msgs,
|
||||
)
|
||||
@ -596,7 +597,7 @@ func (suite *EIP712TestSuite) TestEIP712Tx_DepositAndWithdraw() {
|
||||
}
|
||||
|
||||
// deliver deposit msg
|
||||
gasAmt := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(20)))
|
||||
gasAmt := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(20))
|
||||
txBuilder := suite.createTestEIP712CosmosTxBuilder(
|
||||
suite.testAddr, suite.testPrivKey, ChainID, uint64(helpers.DefaultGenTxGas*10), gasAmt, depositMsgs,
|
||||
)
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
func mustParseDecCoins(value string) sdk.DecCoins {
|
||||
@ -30,7 +31,7 @@ func TestEvmMinGasFilter(t *testing.T) {
|
||||
|
||||
ctx := tApp.NewContext(true, tmproto.Header{Height: 1, Time: tmtime.Now()})
|
||||
tApp.GetEvmKeeper().SetParams(ctx, evmtypes.Params{
|
||||
EvmDenom: "neuron",
|
||||
EvmDenom: chaincfg.EvmDenom,
|
||||
})
|
||||
|
||||
testCases := []struct {
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
)
|
||||
|
||||
func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing.T) {
|
||||
@ -33,7 +34,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"MsgCreateVestingAccount",
|
||||
vesting.NewMsgCreateVestingAccount(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
time.Date(1998, 1, 1, 0, 0, 0, 0, time.UTC).Unix(),
|
||||
false,
|
||||
),
|
||||
@ -44,7 +45,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"MsgCreateVestingAccount",
|
||||
vesting.NewMsgCreatePermanentLockedAccount(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
true,
|
||||
"MsgTypeURL /cosmos.vesting.v1beta1.MsgCreatePermanentLockedAccount not supported",
|
||||
@ -63,7 +64,7 @@ func TestVestingMempoolDecorator_MsgCreateVestingAccount_Unauthorized(t *testing
|
||||
"other messages not affected",
|
||||
banktypes.NewMsgSend(
|
||||
testAddresses[0], testAddresses[1],
|
||||
sdk.NewCoins(sdk.NewInt64Coin("ua0gi", 100)),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100)),
|
||||
),
|
||||
false,
|
||||
"",
|
||||
|
39
app/app.go
39
app/app.go
@ -84,7 +84,6 @@ import (
|
||||
"github.com/evmos/ethermint/x/evm"
|
||||
evmkeeper "github.com/evmos/ethermint/x/evm/keeper"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
"github.com/evmos/ethermint/x/evm/vm/geth"
|
||||
"github.com/evmos/ethermint/x/feemarket"
|
||||
feemarketkeeper "github.com/evmos/ethermint/x/feemarket/keeper"
|
||||
feemarkettypes "github.com/evmos/ethermint/x/feemarket/types"
|
||||
@ -98,6 +97,8 @@ import (
|
||||
"github.com/0glabs/0g-chain/app/ante"
|
||||
chainparams "github.com/0glabs/0g-chain/app/params"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
dasignersprecompile "github.com/0glabs/0g-chain/precompiles/dasigners"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/bep3"
|
||||
bep3keeper "github.com/0glabs/0g-chain/x/bep3/keeper"
|
||||
bep3types "github.com/0glabs/0g-chain/x/bep3/types"
|
||||
@ -108,9 +109,9 @@ import (
|
||||
council "github.com/0glabs/0g-chain/x/council/v1"
|
||||
councilkeeper "github.com/0glabs/0g-chain/x/council/v1/keeper"
|
||||
counciltypes "github.com/0glabs/0g-chain/x/council/v1/types"
|
||||
das "github.com/0glabs/0g-chain/x/das/v1"
|
||||
daskeeper "github.com/0glabs/0g-chain/x/das/v1/keeper"
|
||||
dastypes "github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
dasigners "github.com/0glabs/0g-chain/x/dasigners/v1"
|
||||
dasignerskeeper "github.com/0glabs/0g-chain/x/dasigners/v1/keeper"
|
||||
dasignerstypes "github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
evmutil "github.com/0glabs/0g-chain/x/evmutil"
|
||||
evmutilkeeper "github.com/0glabs/0g-chain/x/evmutil/keeper"
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
@ -123,6 +124,8 @@ import (
|
||||
validatorvesting "github.com/0glabs/0g-chain/x/validator-vesting"
|
||||
validatorvestingrest "github.com/0glabs/0g-chain/x/validator-vesting/client/rest"
|
||||
validatorvestingtypes "github.com/0glabs/0g-chain/x/validator-vesting/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -163,7 +166,7 @@ var (
|
||||
evmutil.AppModuleBasic{},
|
||||
mint.AppModuleBasic{},
|
||||
council.AppModuleBasic{},
|
||||
das.AppModuleBasic{},
|
||||
dasigners.AppModuleBasic{},
|
||||
)
|
||||
|
||||
// module account permissions
|
||||
@ -241,12 +244,12 @@ type App struct {
|
||||
evidenceKeeper evidencekeeper.Keeper
|
||||
transferKeeper ibctransferkeeper.Keeper
|
||||
CouncilKeeper councilkeeper.Keeper
|
||||
DasKeeper daskeeper.Keeper
|
||||
issuanceKeeper issuancekeeper.Keeper
|
||||
bep3Keeper bep3keeper.Keeper
|
||||
pricefeedKeeper pricefeedkeeper.Keeper
|
||||
committeeKeeper committeekeeper.Keeper
|
||||
mintKeeper mintkeeper.Keeper
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
|
||||
// make scoped keepers public for test purposes
|
||||
ScopedIBCKeeper capabilitykeeper.ScopedKeeper
|
||||
@ -295,7 +298,7 @@ func NewApp(
|
||||
committeetypes.StoreKey, evmutiltypes.StoreKey,
|
||||
minttypes.StoreKey,
|
||||
counciltypes.StoreKey,
|
||||
dastypes.StoreKey,
|
||||
dasignerstypes.StoreKey,
|
||||
)
|
||||
tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey, evmtypes.TransientKey, feemarkettypes.TransientKey)
|
||||
memKeys := sdk.NewMemoryStoreKeys(capabilitytypes.MemStoreKey)
|
||||
@ -437,14 +440,23 @@ func NewApp(
|
||||
)
|
||||
|
||||
evmBankKeeper := evmutilkeeper.NewEvmBankKeeper(app.evmutilKeeper, app.bankKeeper, app.accountKeeper)
|
||||
// dasigners keeper
|
||||
app.dasignersKeeper = dasignerskeeper.NewKeeper(keys[dasignerstypes.StoreKey], appCodec, app.stakingKeeper)
|
||||
// precopmiles
|
||||
precompiles := make(map[common.Address]vm.PrecompiledContract)
|
||||
daSignersPrecompile, err := dasignersprecompile.NewDASignersPrecompile(app.dasignersKeeper)
|
||||
if err != nil {
|
||||
panic("initialize precompile failed")
|
||||
}
|
||||
precompiles[daSignersPrecompile.Address()] = daSignersPrecompile
|
||||
// evm keeper
|
||||
app.evmKeeper = evmkeeper.NewKeeper(
|
||||
appCodec, keys[evmtypes.StoreKey], tkeys[evmtypes.TransientKey],
|
||||
govAuthorityAddr,
|
||||
app.accountKeeper, evmBankKeeper, app.stakingKeeper, app.feeMarketKeeper,
|
||||
nil, // precompiled contracts
|
||||
geth.NewEVM,
|
||||
options.EVMTrace,
|
||||
evmSubspace,
|
||||
precompiles,
|
||||
)
|
||||
|
||||
app.evmutilKeeper.SetEvmKeeper(app.evmKeeper)
|
||||
@ -558,7 +570,6 @@ func NewApp(
|
||||
app.CouncilKeeper = councilkeeper.NewKeeper(
|
||||
keys[counciltypes.StoreKey], appCodec, app.stakingKeeper,
|
||||
)
|
||||
app.DasKeeper = daskeeper.NewKeeper(keys[dastypes.StoreKey], appCodec, app.stakingKeeper)
|
||||
|
||||
// create the module manager (Note: Any module instantiated in the module manager that is later modified
|
||||
// must be passed by reference here.)
|
||||
@ -590,7 +601,7 @@ func NewApp(
|
||||
// nil InflationCalculationFn, use SDK's default inflation function
|
||||
mint.NewAppModule(appCodec, app.mintKeeper, app.accountKeeper, chaincfg.CustomInflationCalculateFn),
|
||||
council.NewAppModule(app.CouncilKeeper, app.stakingKeeper),
|
||||
das.NewAppModule(app.DasKeeper),
|
||||
dasigners.NewAppModule(app.dasignersKeeper, app.stakingKeeper),
|
||||
)
|
||||
|
||||
// Warning: Some begin blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -634,7 +645,7 @@ func NewApp(
|
||||
evmutiltypes.ModuleName,
|
||||
|
||||
counciltypes.ModuleName,
|
||||
dastypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some end blockers must run before others. Ensure the dependencies are understood before modifying this list.
|
||||
@ -667,7 +678,7 @@ func NewApp(
|
||||
evmutiltypes.ModuleName,
|
||||
minttypes.ModuleName,
|
||||
counciltypes.ModuleName,
|
||||
dastypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
// Warning: Some init genesis methods must run before others. Ensure the dependencies are understood before modifying this list
|
||||
@ -699,7 +710,7 @@ func NewApp(
|
||||
upgradetypes.ModuleName,
|
||||
validatorvestingtypes.ModuleName,
|
||||
counciltypes.ModuleName,
|
||||
dastypes.ModuleName,
|
||||
dasignerstypes.ModuleName,
|
||||
)
|
||||
|
||||
app.mm.RegisterInvariants(&app.crisisKeeper)
|
||||
|
@ -3,10 +3,6 @@ package app
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -19,6 +15,10 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmtypes "github.com/tendermint/tendermint/types"
|
||||
db "github.com/tendermint/tm-db"
|
||||
"os"
|
||||
"sort"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestNewApp(t *testing.T) {
|
||||
|
@ -149,7 +149,7 @@ func GenesisStateWithSingleValidator(
|
||||
balances := []banktypes.Balance{
|
||||
{
|
||||
Address: acc.GetAddress().String(),
|
||||
Coins: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(100000000000000))),
|
||||
Coins: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(100000000000000)),
|
||||
},
|
||||
}
|
||||
|
||||
@ -212,7 +212,7 @@ func genesisStateWithValSet(
|
||||
}
|
||||
// set validators and delegations
|
||||
currentStakingGenesis := stakingtypes.GetGenesisStateFromAppState(app.appCodec, genesisState)
|
||||
currentStakingGenesis.Params.BondDenom = "ua0gi"
|
||||
currentStakingGenesis.Params.BondDenom = chaincfg.GasDenom // TODO:
|
||||
|
||||
stakingGenesis := stakingtypes.NewGenesisState(
|
||||
currentStakingGenesis.Params,
|
||||
@ -232,13 +232,13 @@ func genesisStateWithValSet(
|
||||
|
||||
for range delegations {
|
||||
// add delegated tokens to total supply
|
||||
totalSupply = totalSupply.Add(sdk.NewCoin("ua0gi", bondAmt))
|
||||
totalSupply = totalSupply.Add(chaincfg.MakeCoinForGasDenom(bondAmt))
|
||||
}
|
||||
|
||||
// add bonded amount to bonded pool module account
|
||||
balances = append(balances, banktypes.Balance{
|
||||
Address: authtypes.NewModuleAddress(stakingtypes.BondedPoolName).String(),
|
||||
Coins: sdk.Coins{sdk.NewCoin("ua0gi", bondAmt)},
|
||||
Coins: sdk.Coins{chaincfg.MakeCoinForGasDenom(bondAmt)},
|
||||
})
|
||||
|
||||
bankGenesis := banktypes.NewGenesisState(
|
||||
|
57
chaincfg/coin_helper.go
Normal file
57
chaincfg/coin_helper.go
Normal file
@ -0,0 +1,57 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
func toBigInt(amount any) *big.Int {
|
||||
if amount == nil {
|
||||
return big.NewInt(0)
|
||||
}
|
||||
var val *big.Int
|
||||
switch amount.(type) {
|
||||
case int:
|
||||
val = big.NewInt(int64(amount.(int)))
|
||||
case int32:
|
||||
val = big.NewInt(int64(amount.(int32)))
|
||||
case int64:
|
||||
val = big.NewInt(amount.(int64))
|
||||
case string:
|
||||
var ok bool
|
||||
val, ok = new(big.Int).SetString(amount.(string), 0)
|
||||
if !ok {
|
||||
panic(fmt.Sprintf("invalid amount string: %s", amount.(string)))
|
||||
}
|
||||
case math.Int:
|
||||
val = amount.(math.Int).BigInt()
|
||||
case *big.Int:
|
||||
val = amount.(*big.Int)
|
||||
case float64:
|
||||
val = decimal.NewFromFloat(amount.(float64)).BigInt()
|
||||
default:
|
||||
panic(fmt.Sprintf("invalid amount type: %T", amount))
|
||||
}
|
||||
|
||||
return val
|
||||
}
|
||||
|
||||
func MakeCoinForStandardDenom(amount any) sdk.Coin {
|
||||
return makeCoin(StandardDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func MakeCoinForGasDenom(amount any) sdk.Coin {
|
||||
return makeCoin(GasDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func MakeCoinForEvmDenom(amount any) sdk.Coin {
|
||||
return makeCoin(EvmDenom, toBigInt(amount))
|
||||
}
|
||||
|
||||
func makeCoin(denom string, amount *big.Int) sdk.Coin {
|
||||
return sdk.NewCoin(denom, math.NewIntFromBigInt(amount))
|
||||
}
|
37
chaincfg/denoms.go
Normal file
37
chaincfg/denoms.go
Normal file
@ -0,0 +1,37 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const (
|
||||
StandardDenom = "a0gi"
|
||||
|
||||
GasDenom = "ua0gi"
|
||||
|
||||
EvmDenom = "neuron"
|
||||
|
||||
BondDenom = EvmDenom
|
||||
|
||||
GasDenomUnit = 6
|
||||
|
||||
EvmDenomUnit = 18
|
||||
|
||||
GasDenomConversionMultiplier = 1e12
|
||||
EvmDenomConversionMultiplier = 1e18
|
||||
)
|
||||
|
||||
// RegisterDenoms registers the base and gas denominations to the SDK.
|
||||
func RegisterDenoms() {
|
||||
if err := sdk.RegisterDenom(StandardDenom, sdk.OneDec()); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := sdk.RegisterDenom(GasDenom, sdk.NewDecWithPrec(1, GasDenomUnit)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if err := sdk.RegisterDenom(EvmDenom, sdk.NewDecWithPrec(1, EvmDenomUnit)); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
80
chaincfg/denoms_test.go
Normal file
80
chaincfg/denoms_test.go
Normal file
@ -0,0 +1,80 @@
|
||||
package chaincfg
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestRegisterDenoms(t *testing.T) {
|
||||
RegisterDenoms()
|
||||
tests := []struct {
|
||||
name string
|
||||
from sdk.Coin
|
||||
targetDenom string
|
||||
expCoin sdk.Coin
|
||||
expErr error
|
||||
}{
|
||||
{
|
||||
"standard to gas",
|
||||
MakeCoinForStandardDenom(99),
|
||||
GasDenom,
|
||||
MakeCoinForGasDenom(99 * (EvmDenomConversionMultiplier / GasDenomConversionMultiplier)),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"gas to standard",
|
||||
MakeCoinForGasDenom(5e7),
|
||||
StandardDenom,
|
||||
MakeCoinForStandardDenom(50),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"standard to base",
|
||||
MakeCoinForStandardDenom(22),
|
||||
EvmDenom,
|
||||
MakeCoinForEvmDenom(22 * EvmDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"base to standard",
|
||||
MakeCoinForEvmDenom("97000000000000000000"),
|
||||
StandardDenom,
|
||||
MakeCoinForStandardDenom(97),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"gas to base",
|
||||
MakeCoinForGasDenom(33),
|
||||
EvmDenom,
|
||||
MakeCoinForEvmDenom(33 * GasDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
{
|
||||
"base to gas",
|
||||
MakeCoinForEvmDenom("770000000000000"),
|
||||
GasDenom,
|
||||
MakeCoinForGasDenom(770000000000000 / GasDenomConversionMultiplier),
|
||||
nil,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
ret, err := sdk.ConvertCoin(tt.from, tt.targetDenom)
|
||||
if tt.expErr != nil {
|
||||
if err == nil {
|
||||
t.Errorf("expErr is not nil, but got nil")
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if err != nil {
|
||||
t.Errorf("expErr is nil, but got %v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
assert.Equal(t, tt.expCoin, ret)
|
||||
})
|
||||
}
|
||||
}
|
@ -73,7 +73,7 @@ func TestKvCLIKeysAddRecover(t *testing.T) {
|
||||
f.Cleanup()
|
||||
}
|
||||
|
||||
func TestKavaCLIKeysAddRecoverHDPath(t *testing.T) {
|
||||
func TestZgChainCLIKeysAddRecoverHDPath(t *testing.T) {
|
||||
t.Parallel()
|
||||
f := InitFixtures(t)
|
||||
|
||||
|
@ -72,7 +72,7 @@ func NewRootCmd() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
customAppTemplate, customAppConfig := servercfg.AppConfig("ua0gi")
|
||||
customAppTemplate, customAppConfig := servercfg.AppConfig(chaincfg.GasDenom)
|
||||
|
||||
return server.InterceptConfigsPreRunHandler(
|
||||
cmd,
|
||||
@ -123,7 +123,7 @@ func addSubCmds(rootCmd *cobra.Command, encodingConfig params.EncodingConfig, de
|
||||
ac.addStartCmdFlags,
|
||||
)
|
||||
|
||||
// add keybase, auxiliary RPC, query, and tx child commands
|
||||
// add keybase, gas RPC, query, and tx child commands
|
||||
rootCmd.AddCommand(
|
||||
newQueryCmd(),
|
||||
newTxCmd(),
|
||||
|
166
crypto/bn254util/bn254util.go
Normal file
166
crypto/bn254util/bn254util.go
Normal file
@ -0,0 +1,166 @@
|
||||
package bn254util
|
||||
|
||||
import (
|
||||
"math/big"
|
||||
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254/fp"
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254/fr"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
)
|
||||
|
||||
const (
|
||||
G1PointSize = 32 * 2
|
||||
G2PointSize = 32 * 2 * 2
|
||||
)
|
||||
|
||||
var (
|
||||
FR_MODULUS, _ = new(big.Int).SetString("21888242871839275222246405745257275088548364400416034343698204186575808495617", 10)
|
||||
)
|
||||
|
||||
func VerifySig(sig *bn254.G1Affine, pubkey *bn254.G2Affine, msgBytes [32]byte) (bool, error) {
|
||||
|
||||
g2Gen := GetG2Generator()
|
||||
|
||||
msgPoint := MapToCurve(msgBytes)
|
||||
|
||||
var negSig bn254.G1Affine
|
||||
negSig.Neg((*bn254.G1Affine)(sig))
|
||||
|
||||
P := [2]bn254.G1Affine{*msgPoint, negSig}
|
||||
Q := [2]bn254.G2Affine{*pubkey, *g2Gen}
|
||||
|
||||
ok, err := bn254.PairingCheck(P[:], Q[:])
|
||||
if err != nil {
|
||||
return false, nil
|
||||
}
|
||||
return ok, nil
|
||||
|
||||
}
|
||||
|
||||
func MapToCurve(digest [32]byte) *bn254.G1Affine {
|
||||
|
||||
one := new(big.Int).SetUint64(1)
|
||||
three := new(big.Int).SetUint64(3)
|
||||
x := new(big.Int)
|
||||
x.SetBytes(digest[:])
|
||||
for {
|
||||
// y = x^3 + 3
|
||||
xP3 := new(big.Int).Exp(x, big.NewInt(3), fp.Modulus())
|
||||
y := new(big.Int).Add(xP3, three)
|
||||
y.Mod(y, fp.Modulus())
|
||||
|
||||
if y.ModSqrt(y, fp.Modulus()) == nil {
|
||||
x.Add(x, one).Mod(x, fp.Modulus())
|
||||
} else {
|
||||
var fpX, fpY fp.Element
|
||||
fpX.SetBigInt(x)
|
||||
fpY.SetBigInt(y)
|
||||
return &bn254.G1Affine{
|
||||
X: fpX,
|
||||
Y: fpY,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func CheckG1AndG2DiscreteLogEquality(pointG1 *bn254.G1Affine, pointG2 *bn254.G2Affine) (bool, error) {
|
||||
negGenG1 := new(bn254.G1Affine).Neg(GetG1Generator())
|
||||
return bn254.PairingCheck([]bn254.G1Affine{*pointG1, *negGenG1}, []bn254.G2Affine{*GetG2Generator(), *pointG2})
|
||||
}
|
||||
|
||||
func GetG1Generator() *bn254.G1Affine {
|
||||
g1Gen := new(bn254.G1Affine)
|
||||
_, err := g1Gen.X.SetString("1")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
_, err = g1Gen.Y.SetString("2")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
return g1Gen
|
||||
}
|
||||
|
||||
func GetG2Generator() *bn254.G2Affine {
|
||||
g2Gen := new(bn254.G2Affine)
|
||||
g2Gen.X.SetString("10857046999023057135944570762232829481370756359578518086990519993285655852781",
|
||||
"11559732032986387107991004021392285783925812861821192530917403151452391805634")
|
||||
g2Gen.Y.SetString("8495653923123431417604973247489272438418190587263600148770280649306958101930",
|
||||
"4082367875863433681332203403145435568316851327593401208105741076214120093531")
|
||||
return g2Gen
|
||||
}
|
||||
|
||||
func MulByGeneratorG1(a *fr.Element) *bn254.G1Affine {
|
||||
g1Gen := GetG1Generator()
|
||||
return new(bn254.G1Affine).ScalarMultiplication(g1Gen, a.BigInt(new(big.Int)))
|
||||
}
|
||||
|
||||
func MulByGeneratorG2(a *fr.Element) *bn254.G2Affine {
|
||||
g2Gen := GetG2Generator()
|
||||
return new(bn254.G2Affine).ScalarMultiplication(g2Gen, a.BigInt(new(big.Int)))
|
||||
}
|
||||
|
||||
func SerializeG1(p *bn254.G1Affine) []byte {
|
||||
b := make([]byte, 0)
|
||||
tmp := p.X.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.Y.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func DeserializeG1(b []byte) *bn254.G1Affine {
|
||||
p := new(bn254.G1Affine)
|
||||
p.X.SetBytes(b[0:32])
|
||||
p.Y.SetBytes(b[32:64])
|
||||
return p
|
||||
}
|
||||
|
||||
func SerializeG2(p *bn254.G2Affine) []byte {
|
||||
b := make([]byte, 0)
|
||||
tmp := p.X.A0.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.X.A1.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.Y.A0.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
tmp = p.Y.A1.Bytes()
|
||||
for i := 0; i < 32; i++ {
|
||||
b = append(b, tmp[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func DeserializeG2(b []byte) *bn254.G2Affine {
|
||||
p := new(bn254.G2Affine)
|
||||
p.X.A0.SetBytes(b[0:32])
|
||||
p.X.A1.SetBytes(b[32:64])
|
||||
p.Y.A0.SetBytes(b[64:96])
|
||||
p.Y.A1.SetBytes(b[96:128])
|
||||
return p
|
||||
}
|
||||
|
||||
func Gamma(hash *bn254.G1Affine, signature *bn254.G1Affine, pkG1 *bn254.G1Affine, pkG2 *bn254.G2Affine) *big.Int {
|
||||
toHash := make([]byte, 0)
|
||||
toHash = append(toHash, SerializeG1(hash)...)
|
||||
toHash = append(toHash, SerializeG1(signature)...)
|
||||
toHash = append(toHash, SerializeG1(pkG1)...)
|
||||
toHash = append(toHash, SerializeG2(pkG2)...)
|
||||
|
||||
msgHash := crypto.Keccak256(toHash)
|
||||
gamma := new(big.Int)
|
||||
gamma.SetBytes(msgHash)
|
||||
gamma.Mod(gamma, FR_MODULUS)
|
||||
return gamma
|
||||
}
|
10
go.mod
10
go.mod
@ -7,6 +7,7 @@ require (
|
||||
cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4
|
||||
github.com/cenkalti/backoff/v4 v4.1.3
|
||||
github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71
|
||||
github.com/consensys/gnark-crypto v0.12.1
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.3
|
||||
github.com/cosmos/cosmos-sdk v0.46.11
|
||||
github.com/cosmos/go-bip39 v1.0.0
|
||||
@ -21,6 +22,7 @@ require (
|
||||
github.com/linxGnu/grocksdb v1.8.0
|
||||
github.com/pelletier/go-toml/v2 v2.0.6
|
||||
github.com/prometheus/client_golang v1.14.0
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/spf13/cast v1.5.0
|
||||
github.com/spf13/cobra v1.6.1
|
||||
github.com/spf13/viper v1.15.0
|
||||
@ -55,6 +57,7 @@ require (
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
|
||||
github.com/bgentry/speakeasy v0.1.0 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.7.0 // indirect
|
||||
github.com/btcsuite/btcd v0.23.4 // indirect
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 // indirect
|
||||
github.com/btcsuite/btcd/btcutil v1.1.3 // indirect
|
||||
@ -66,6 +69,7 @@ require (
|
||||
github.com/coinbase/rosetta-sdk-go v0.7.9 // indirect
|
||||
github.com/cometbft/cometbft-db v0.7.0 // indirect
|
||||
github.com/confio/ics23/go v0.9.0 // indirect
|
||||
github.com/consensys/bavard v0.1.13 // indirect
|
||||
github.com/cosmos/btcutil v1.0.5 // indirect
|
||||
github.com/cosmos/gogoproto v1.4.6 // indirect
|
||||
github.com/cosmos/iavl v0.19.5 // indirect
|
||||
@ -145,6 +149,7 @@ require (
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/go-testing-interface v1.14.1 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mmcloughlin/addchain v0.4.0 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mtibben/percent v0.2.1 // indirect
|
||||
@ -198,6 +203,7 @@ require (
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
nhooyr.io/websocket v1.8.6 // indirect
|
||||
rsc.io/tmplfunc v0.0.3 // indirect
|
||||
)
|
||||
|
||||
replace (
|
||||
@ -210,8 +216,10 @@ replace (
|
||||
github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-0glabs.4
|
||||
// See https://github.com/cosmos/cosmos-sdk/pull/13093
|
||||
github.com/dgrijalva/jwt-go => github.com/golang-jwt/jwt/v4 v4.4.2
|
||||
// Use go-ethereum fork with precompiles
|
||||
github.com/ethereum/go-ethereum => github.com/evmos/go-ethereum v1.10.26-evmos-rc2
|
||||
// Use ethermint fork that respects min-gas-price with NoBaseFee true and london enabled, and includes eip712 support
|
||||
github.com/evmos/ethermint => github.com/kava-labs/ethermint v0.21.0-kava-v23-1
|
||||
github.com/evmos/ethermint => github.com/0glabs/ethermint v0.21.0-0g.v2.0.1
|
||||
// See https://github.com/cosmos/cosmos-sdk/pull/10401, https://github.com/cosmos/cosmos-sdk/commit/0592ba6158cd0bf49d894be1cef4faeec59e8320
|
||||
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.7.0
|
||||
// Use the cosmos modified protobufs
|
||||
|
49
go.sum
49
go.sum
@ -204,6 +204,8 @@ git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFN
|
||||
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA=
|
||||
github.com/0glabs/cosmos-sdk v0.46.11-0glabs.4 h1:NYKYgJIilexHR8VE1EAl7Tv2wMQGPwdzKiLV2DnIAwg=
|
||||
github.com/0glabs/cosmos-sdk v0.46.11-0glabs.4/go.mod h1:jwgWoeAWxqMF5pZUZ4N+G4rD3q6oOLulq3/dGCFLEX4=
|
||||
github.com/0glabs/ethermint v0.21.0-0g.v2.0.1 h1:loFnZAEZ8tboo3JO3+AE+1gJcUm6hkYuwcn+ZHBhjxE=
|
||||
github.com/0glabs/ethermint v0.21.0-0g.v2.0.1/go.mod h1:peUmQT71k9BOBgoWoIRWRrM/O01mffVjIH0RLnoaFuI=
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 h1:/vQbFIOMbk2FiG/kXiLl8BRyzTWDw7gX/Hz7Dd5eDMs=
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4/go.mod h1:hN7oaIRCjzsZ2dE+yG5k+rsdt3qcwykqK6HVGcKwsw4=
|
||||
github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.1/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM=
|
||||
@ -211,6 +213,7 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSu
|
||||
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.3.0/go.mod h1:tPaiy8S5bQ+S5sOiDlINkp7+Ef339+Nz5L5XO+cnOHo=
|
||||
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 h1:UQHMgLO+TxOElx5B5HZ4hJQsoJ/PvUvKRhJHDQXO8P8=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d h1:nalkkPQcITbvhmL4+C4cKA87NW0tfm3Kl9VXRoPywFg=
|
||||
github.com/ChainSafe/go-schnorrkel v0.0.0-20200405005733-88cbf1b4c40d/go.mod h1:URdX5+vg25ts3aCh8H5IFZybJYKWhJHYMTnf+ULtoC4=
|
||||
@ -280,6 +283,8 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1U
|
||||
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4=
|
||||
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
|
||||
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
|
||||
github.com/bits-and-blooms/bitset v1.7.0 h1:YjAGVd3XmtK9ktAbX8Zg2g2PwLIMjGREZJHlV4j7NEo=
|
||||
github.com/bits-and-blooms/bitset v1.7.0/go.mod h1:gIdJ4wp64HaoK2YrL1Q5/N7Y16edYb8uY+O0FJTyyDA=
|
||||
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
|
||||
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
|
||||
github.com/btcsuite/btcd v0.0.0-20190315201642-aa6e0f35703c/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
|
||||
@ -291,8 +296,8 @@ github.com/btcsuite/btcd v0.23.0/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZg
|
||||
github.com/btcsuite/btcd v0.23.4 h1:IzV6qqkfwbItOS/sg/aDfPDsjPP8twrCOE2R93hxMlQ=
|
||||
github.com/btcsuite/btcd v0.23.4/go.mod h1:0QJIIN1wwIXF/3G/m87gIwGniDMDQqjVn4SZgnFpsYY=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.0/go.mod h1:2VzYrv4Gm4apmbVVsSq5bqf1Ec8v56E48Vt0Y/umPgA=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.1.3/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2 h1:5n0X6hX0Zk+6omWcihdYvdAlGf2DfasC0GMf7DClJ3U=
|
||||
github.com/btcsuite/btcd/btcec/v2 v2.3.2/go.mod h1:zYzJ8etWJQIv1Ogk7OzpWjowwOdXY1W/17j2MW85J04=
|
||||
github.com/btcsuite/btcd/btcutil v1.0.0/go.mod h1:Uoxwv0pqYWhD//tfTiipkxNfdhG9UrLwaeswfjfdF0A=
|
||||
@ -364,8 +369,12 @@ github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71 h1:MFLTqgfJcl
|
||||
github.com/coniks-sys/coniks-go v0.0.0-20180722014011-11acf4819b71/go.mod h1:TrHYHH4Wze7v7Hkwu1MH1W+mCPQKM+gs+PicdEV14o8=
|
||||
github.com/consensys/bavard v0.1.8-0.20210406032232-f3452dc9b572/go.mod h1:Bpd0/3mZuaj6Sj+PqrmIquiOKy397AKGThQPaGzNXAQ=
|
||||
github.com/consensys/bavard v0.1.8-0.20210915155054-088da2f7f54a/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
|
||||
github.com/consensys/bavard v0.1.13/go.mod h1:9ItSMtA/dXMAiL7BG6bqW2m3NdSEObYWoH223nGHukI=
|
||||
github.com/consensys/gnark-crypto v0.4.1-0.20210426202927-39ac3d4b3f1f/go.mod h1:815PAHg3wvysy0SyIqanF8gZ0Y1wjk/hrDHD/iT88+Q=
|
||||
github.com/consensys/gnark-crypto v0.5.3/go.mod h1:hOdPlWQV1gDLp7faZVeg8Y0iEPFaOUnCc4XeCCk96p0=
|
||||
github.com/consensys/gnark-crypto v0.12.1 h1:lHH39WuuFgVHONRl3J0LRBtuYdQTumFSDtJF7HpyG8M=
|
||||
github.com/consensys/gnark-crypto v0.12.1/go.mod h1:v2Gy7L/4ZRosZ7Ivs+9SfUDr0f5UlG+EM5t7MPHiLuY=
|
||||
github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvAXZJ/eg=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
@ -436,10 +445,9 @@ github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91 h1:Izz0+t1Z5nI16
|
||||
github.com/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||
github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko=
|
||||
github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ=
|
||||
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/docker v1.6.2/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||
github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ=
|
||||
github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4=
|
||||
github.com/dop251/goja v0.0.0-20211011172007-d99e4b8cbf48/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
|
||||
github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf h1:Yt+4K30SdjOkRoRRm3vYNQgR+/ZIy0RmeUDZo7Y8zeQ=
|
||||
github.com/dop251/goja v0.0.0-20220405120441-9037c2b61cbf/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
|
||||
github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y=
|
||||
@ -465,13 +473,13 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m
|
||||
github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0=
|
||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/ethereum/go-ethereum v1.10.17/go.mod h1:Lt5WzjM07XlXc95YzrhosmR4J9Ahd6X2wyEV2SvGhk0=
|
||||
github.com/ethereum/go-ethereum v1.10.26 h1:i/7d9RBBwiXCEuyduBQzJw/mKmnvzsN14jqBmytw72s=
|
||||
github.com/ethereum/go-ethereum v1.10.26/go.mod h1:EYFyF19u3ezGLD4RqOkLq+ZCXzYbLoNDdZlMt7kyKFg=
|
||||
github.com/evmos/go-ethereum v1.10.26-evmos-rc2 h1:tYghk1ZZ8X4/OQ4YI9hvtm8aSN8OSqO0g9vo/sCMdBo=
|
||||
github.com/evmos/go-ethereum v1.10.26-evmos-rc2/go.mod h1:/6CsT5Ceen2WPLI/oCA3xMcZ5sWMF/D46SjM/ayY0Oo=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/felixge/httpsnoop v1.0.1 h1:lvB5Jl89CsZtGIWuTcDM1E/vkVs49/Ml7JJe07l8SPQ=
|
||||
github.com/felixge/httpsnoop v1.0.1/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
|
||||
github.com/fjl/gencodec v0.0.0-20220412091415-8bb9e558978c/go.mod h1:AzA8Lj6YtixmJWL+wkKoBGsLWy9gFrAzi4g+5bCKwpY=
|
||||
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c=
|
||||
github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0=
|
||||
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
|
||||
@ -483,6 +491,7 @@ github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMo
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY=
|
||||
github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw=
|
||||
github.com/garslo/gogen v0.0.0-20170306192744-1d203ffc1f61/go.mod h1:Q0X6pkwTILDlzrGEckF6HKjXe48EgsY/l7K7vhY4MW8=
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI=
|
||||
github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww=
|
||||
github.com/getkin/kin-openapi v0.53.0/go.mod h1:7Yn5whZr5kJi6t+kShccXS8ae1APpYTW6yheSwk8Yi4=
|
||||
@ -652,6 +661,7 @@ github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLe
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/s2a-go v0.1.4 h1:1kZ/sQM3srePvKs3tXAvQzo66XfcReoqFpIpIccE7Oc=
|
||||
github.com/google/s2a-go v0.1.4/go.mod h1:Ej+mSEMGRnqRzjc7VtF+jdBwYG5fuJfiZ8ELkjEwM0A=
|
||||
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
@ -754,7 +764,6 @@ github.com/holiman/uint256 v1.2.1 h1:XRtyuda/zw2l+Bq/38n5XUoEF72aSOu/77Thd9pPp2o
|
||||
github.com/holiman/uint256 v1.2.1/go.mod h1:y4ga/t+u+Xwd7CpDgZESaRcWy0I7XMlTMA25ApIH5Jw=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg=
|
||||
github.com/huin/goupnp v1.0.3-0.20220313090229-ca81a64b4204/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
|
||||
github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
|
||||
github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y=
|
||||
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
|
||||
@ -813,8 +822,6 @@ github.com/kava-labs/cometbft v0.34.27-kava.0 h1:FUEGRkF3xtrJH+h9A5G4eA2skf7QaNo
|
||||
github.com/kava-labs/cometbft v0.34.27-kava.0/go.mod h1:BcCbhKv7ieM0KEddnYXvQZR+pZykTKReJJYf7YC7qhw=
|
||||
github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1 h1:EZnZAkZ+dqK+1OM4AK+e6wYH8a5xuyg4yFTR4Ez3AXk=
|
||||
github.com/kava-labs/cometbft-db v0.7.0-rocksdb-v7.9.2-kava.1/go.mod h1:mI/4J4IxRzPrXvMiwefrt0fucGwaQ5Hm9IKS7HnoJeI=
|
||||
github.com/kava-labs/ethermint v0.21.0-kava-v23-1 h1:5TSyCtPvFdMuSe8p2iMVqXmFBlK3lHyjaT9EqN752aI=
|
||||
github.com/kava-labs/ethermint v0.21.0-kava-v23-1/go.mod h1:rdm6AinxZ4dzPEv/cjH+/AGyTbKufJ3RE7M2MDyklH0=
|
||||
github.com/kava-labs/tm-db v0.6.7-kava.4 h1:M2RibOKmbi+k2OhAFry8z9+RJF0CYuDETB7/PrSdoro=
|
||||
github.com/kava-labs/tm-db v0.6.7-kava.4/go.mod h1:70tpLhNfwCP64nAlq+bU+rOiVfWr3Nnju1D1nhGDGKs=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
@ -842,9 +849,11 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758/go.mod h1:B69LEHPfb2qLo0BaaOLcbitczOKLWTsrBG9LczfCD4k=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/labstack/echo/v4 v4.2.1/go.mod h1:AA49e0DZ8kk5jTOOCKNuPR6oTnBS0dYiM4FW1e6jwpg=
|
||||
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
|
||||
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w=
|
||||
@ -918,6 +927,9 @@ github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyua
|
||||
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
|
||||
github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A=
|
||||
github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4=
|
||||
github.com/mmcloughlin/addchain v0.4.0 h1:SobOdjm2xLj1KkXN5/n0xTIWyZA2+s99UCY1iPfkHRY=
|
||||
github.com/mmcloughlin/addchain v0.4.0/go.mod h1:A86O+tHqZLMNO4w6ZZ4FlVQEadcoqkyU72HC5wJ4RlU=
|
||||
github.com/mmcloughlin/profile v0.1.1/go.mod h1:IhHD7q1ooxgwTgjxQYkACGA77oFTDdFVejUS1/tS/qU=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
@ -954,6 +966,7 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N
|
||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.3/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.14.0 h1:2mOpI4JVVPBN+WQRa0WKH2eXR+Ey+uK4n7Zj0aYpIQA=
|
||||
github.com/onsi/ginkgo v1.14.0/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
|
||||
@ -1083,6 +1096,8 @@ github.com/segmentio/kafka-go v0.2.0/go.mod h1:X6itGqS9L4jDletMsxZ7Dz+JFWxM6JHfP
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU=
|
||||
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
|
||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
@ -1135,12 +1150,14 @@ github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
|
||||
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/subosito/gotenv v1.4.2 h1:X1TuBLAMDFbaTAChgCBLu3DU3UPyELpnF2jjJ2cz/S8=
|
||||
github.com/subosito/gotenv v1.4.2/go.mod h1:ayKnFf/c6rvx/2iiLrJUk1e6plDbT3edrFNGqEflhK0=
|
||||
github.com/supranational/blst v0.3.8-0.20220526154634-513d2456b344/go.mod h1:jZJtfjgudtNl4en1tzwPIV3KjUnQUvG3/j+w+fVonLw=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY=
|
||||
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc=
|
||||
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
|
||||
@ -1180,6 +1197,7 @@ github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY=
|
||||
github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0=
|
||||
github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI=
|
||||
github.com/urfave/cli/v2 v2.10.2 h1:x3p8awjp/2arX+Nl/G2040AZpOCHS/eMJJ1/a+mye4Y=
|
||||
github.com/urfave/cli/v2 v2.10.2/go.mod h1:f8iq5LtQ/bLxafbdBSLPPNsgaW0l/2fYYEHhAyPlwvo=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPUpymEIMZ47gx8=
|
||||
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||
@ -1190,12 +1208,14 @@ github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q
|
||||
github.com/xlab/treeprint v0.0.0-20180616005107-d6fb6747feb6/go.mod h1:ce1O1j6UtZfjr22oyGxGLbauSBp2YVXpARAosm7dHBg=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
github.com/ybbus/jsonrpc v2.1.2+incompatible/go.mod h1:XJrh1eMSzdIYFbM08flv0wp5G35eRniyeGut1z+LSiE=
|
||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
github.com/zondax/hid v0.9.1 h1:gQe66rtmyZ8VeGFcOpbuH3r7erYtNEAezCAYu8LdkJo=
|
||||
github.com/zondax/hid v0.9.1/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
|
||||
@ -1267,6 +1287,7 @@ golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u0
|
||||
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
|
||||
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
|
||||
golang.org/x/exp v0.0.0-20200331195152-e8c3332aa8e5/go.mod h1:4M0jN8W1tt0AVLNr8HDosyJCDCDuyL9N9+3m7wDWgKw=
|
||||
golang.org/x/exp v0.0.0-20220426173459-3bcf042a4bf5/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb h1:PaBZQdo+iSDyHT053FjUCgZQ/9uqVwPOcl7KSWhKn6w=
|
||||
golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
||||
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
|
||||
@ -1295,6 +1316,8 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
|
||||
golang.org/x/mod v0.6.0-dev.0.20211013180041-c96bc1413d57/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0 h1:LUYupSeNrTNCGzR/hVBk2NHZO4hXcVaW1k4Qx7rjPx8=
|
||||
golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@ -1488,7 +1511,6 @@ golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@ -1567,6 +1589,7 @@ golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191126055441-b0650ceb63d9/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
@ -1605,6 +1628,7 @@ golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||
golang.org/x/tools v0.1.8-0.20211029000441-d6a9af8af023/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
@ -1876,11 +1900,9 @@ gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU=
|
||||
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c=
|
||||
gopkg.in/olebedev/go-duktape.v3 v3.0.0-20200619000410-60c24ae608a6/go.mod h1:uAJfkITjFhyEEuUfm7bsmCZRbW5WRq8s9EY8HZ6hCns=
|
||||
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/urfave/cli.v1 v1.20.0/go.mod h1:vuBzUtMdQeixQj8LVd+/98pzhxNGQoyuPBlsXHOQNO0=
|
||||
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
|
||||
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
@ -1896,8 +1918,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gotest.tools v2.2.0+incompatible h1:VsBPFP1AI068pPrMxtb/S8Zkgf9xEmTLJjfM+P5UIEo=
|
||||
gotest.tools v2.2.0+incompatible/go.mod h1:DsYFclhRJ6vuDpmuTbkuFWG+y2sxOXAzmJt81HFBacw=
|
||||
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
|
||||
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||
@ -1915,6 +1935,7 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
|
||||
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
|
||||
rsc.io/tmplfunc v0.0.3 h1:53XFQh69AfOa8Tw0Jm7t+GV7KZhOi6jzsCzTtKbMvzU=
|
||||
rsc.io/tmplfunc v0.0.3/go.mod h1:AG3sTPzElb1Io3Yg4voV9AGZJuleGAwaVRxL9M49PhA=
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo=
|
||||
|
@ -1,61 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/helper/da/light"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
type DaLightRpcClient interface {
|
||||
Sample(ctx context.Context, streamId, headerHash []byte, blobIdx, times uint32) (bool, error)
|
||||
Destroy()
|
||||
GetInstanceCount() int
|
||||
}
|
||||
|
||||
type daLightClient struct {
|
||||
maxInstance int
|
||||
pool ConnectionPool
|
||||
}
|
||||
|
||||
func NewDaLightClient(address string, instanceLimit int) DaLightRpcClient {
|
||||
return &daLightClient{
|
||||
maxInstance: instanceLimit,
|
||||
pool: NewConnectionPool(address, instanceLimit, 10*time.Minute),
|
||||
}
|
||||
}
|
||||
|
||||
func (c *daLightClient) Sample(ctx context.Context, streamId, headerHash []byte, blobIdx, times uint32) (bool, error) {
|
||||
connection, err := c.pool.GetConnection()
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to connect to da light server")
|
||||
}
|
||||
defer c.pool.ReleaseConnection(connection)
|
||||
|
||||
req := &light.SampleRequest{
|
||||
StreamId: streamId,
|
||||
BatchHeaderHash: headerHash,
|
||||
BlobIndex: blobIdx,
|
||||
Times: times,
|
||||
}
|
||||
client := light.NewLightClient(connection)
|
||||
reply, err := client.Sample(ctx, req)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to sample from da light server")
|
||||
}
|
||||
|
||||
return reply.Success, nil
|
||||
}
|
||||
|
||||
func (c *daLightClient) Destroy() {
|
||||
if c.pool != nil {
|
||||
c.pool.Close()
|
||||
c.pool = nil
|
||||
}
|
||||
}
|
||||
|
||||
func (c *daLightClient) GetInstanceCount() int {
|
||||
return c.maxInstance
|
||||
}
|
@ -1,101 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/backoff"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
type ConnectionPool interface {
|
||||
GetConnection() (*grpc.ClientConn, error)
|
||||
ReleaseConnection(*grpc.ClientConn)
|
||||
Close()
|
||||
}
|
||||
|
||||
type connectionPoolImpl struct {
|
||||
address string
|
||||
maxSize int
|
||||
timeout time.Duration
|
||||
param grpc.ConnectParams
|
||||
|
||||
mu sync.Mutex
|
||||
pool []*grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewConnectionPool(address string, maxSize int, timeout time.Duration) ConnectionPool {
|
||||
return &connectionPoolImpl{
|
||||
address: address,
|
||||
maxSize: maxSize,
|
||||
timeout: timeout,
|
||||
param: grpc.ConnectParams{
|
||||
Backoff: backoff.Config{
|
||||
BaseDelay: 1.0 * time.Second,
|
||||
Multiplier: 1.5,
|
||||
Jitter: 0.2,
|
||||
MaxDelay: 30 * time.Second,
|
||||
},
|
||||
MinConnectTimeout: 30 * time.Second,
|
||||
},
|
||||
pool: make([]*grpc.ClientConn, 0, maxSize),
|
||||
}
|
||||
}
|
||||
|
||||
func (p *connectionPoolImpl) GetConnection() (*grpc.ClientConn, error) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
if p.pool == nil {
|
||||
return nil, errors.New("connection pool is closed")
|
||||
}
|
||||
|
||||
// Check if there's any available connection in the pool
|
||||
if len(p.pool) > 0 {
|
||||
conn := p.pool[0]
|
||||
p.pool = p.pool[1:]
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
// If the pool is empty, create a new connection
|
||||
conn, err := grpc.Dial(p.address, grpc.WithBlock(),
|
||||
grpc.WithConnectParams(p.param),
|
||||
grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return conn, nil
|
||||
}
|
||||
|
||||
func (p *connectionPoolImpl) ReleaseConnection(conn *grpc.ClientConn) {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
if p.pool != nil {
|
||||
// If the pool is full, close the connection
|
||||
if len(p.pool) >= p.maxSize {
|
||||
conn.Close()
|
||||
return
|
||||
}
|
||||
|
||||
// Add the connection back to the pool
|
||||
p.pool = append(p.pool, conn)
|
||||
} else {
|
||||
conn.Close()
|
||||
}
|
||||
}
|
||||
|
||||
func (p *connectionPoolImpl) Close() {
|
||||
p.mu.Lock()
|
||||
defer p.mu.Unlock()
|
||||
|
||||
if p.pool != nil {
|
||||
for _, conn := range p.pool {
|
||||
conn.Close()
|
||||
}
|
||||
|
||||
p.pool = nil
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
module github.com/0glabs/0g-chain/helper/da
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/lesismal/nbio v1.5.4
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/rs/zerolog v1.32.0
|
||||
google.golang.org/grpc v1.63.2
|
||||
google.golang.org/protobuf v1.33.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/lesismal/llib v1.1.13 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/stretchr/testify v1.8.4 // indirect
|
||||
golang.org/x/crypto v0.19.0 // indirect
|
||||
golang.org/x/net v0.21.0 // indirect
|
||||
golang.org/x/sys v0.17.0 // indirect
|
||||
golang.org/x/text v0.14.0 // indirect
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de // indirect
|
||||
)
|
@ -1,60 +0,0 @@
|
||||
github.com/coreos/go-systemd/v22 v22.5.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/lesismal/llib v1.1.13 h1:+w1+t0PykXpj2dXQck0+p6vdC9/mnbEXHgUy/HXDGfE=
|
||||
github.com/lesismal/llib v1.1.13/go.mod h1:70tFXXe7P1FZ02AU9l8LgSOK7d7sRrpnkUr3rd3gKSg=
|
||||
github.com/lesismal/nbio v1.5.4 h1:fZ6FOVZOBm7nFuudYsq+WyHJuM2UNuPdlvF/1LVa6lo=
|
||||
github.com/lesismal/nbio v1.5.4/go.mod h1:mvfYBAA1jmrafXf2XvkM28jWkMTfA5jGks+HKDBMmOc=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
|
||||
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
golang.org/x/crypto v0.0.0-20210513122933-cd7d49e622d5/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
|
||||
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
|
||||
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de h1:cZGRis4/ot9uVm639a+rHCUaG0JJHEsdyzSQTMX+suY=
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240227224415-6ceb2ff114de/go.mod h1:H4O17MA/PE9BsGx3w+a+W2VOLLD1Qf7oJneAoU6WktY=
|
||||
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
|
||||
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
|
||||
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
@ -1,397 +0,0 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.1
|
||||
// protoc v4.25.3
|
||||
// source: light/light.proto
|
||||
|
||||
package light
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
// SampleRequest contains the blob to sample (by batch and blob index) and required sample times
|
||||
type SampleRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
StreamId []byte `protobuf:"bytes,1,opt,name=stream_id,json=streamId,proto3" json:"stream_id,omitempty"`
|
||||
BatchHeaderHash []byte `protobuf:"bytes,2,opt,name=batch_header_hash,json=batchHeaderHash,proto3" json:"batch_header_hash,omitempty"`
|
||||
BlobIndex uint32 `protobuf:"varint,3,opt,name=blob_index,json=blobIndex,proto3" json:"blob_index,omitempty"`
|
||||
Times uint32 `protobuf:"varint,4,opt,name=times,proto3" json:"times,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SampleRequest) Reset() {
|
||||
*x = SampleRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_light_light_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SampleRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SampleRequest) ProtoMessage() {}
|
||||
|
||||
func (x *SampleRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_light_light_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SampleRequest.ProtoReflect.Descriptor instead.
|
||||
func (*SampleRequest) Descriptor() ([]byte, []int) {
|
||||
return file_light_light_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *SampleRequest) GetStreamId() []byte {
|
||||
if x != nil {
|
||||
return x.StreamId
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SampleRequest) GetBatchHeaderHash() []byte {
|
||||
if x != nil {
|
||||
return x.BatchHeaderHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *SampleRequest) GetBlobIndex() uint32 {
|
||||
if x != nil {
|
||||
return x.BlobIndex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *SampleRequest) GetTimes() uint32 {
|
||||
if x != nil {
|
||||
return x.Times
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// SampleReply contains the sample result
|
||||
type SampleReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"`
|
||||
}
|
||||
|
||||
func (x *SampleReply) Reset() {
|
||||
*x = SampleReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_light_light_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *SampleReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*SampleReply) ProtoMessage() {}
|
||||
|
||||
func (x *SampleReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_light_light_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use SampleReply.ProtoReflect.Descriptor instead.
|
||||
func (*SampleReply) Descriptor() ([]byte, []int) {
|
||||
return file_light_light_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *SampleReply) GetSuccess() bool {
|
||||
if x != nil {
|
||||
return x.Success
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
type RetrieveRequest struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
BatchHeaderHash []byte `protobuf:"bytes,1,opt,name=batch_header_hash,json=batchHeaderHash,proto3" json:"batch_header_hash,omitempty"`
|
||||
BlobIndex uint32 `protobuf:"varint,2,opt,name=blob_index,json=blobIndex,proto3" json:"blob_index,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RetrieveRequest) Reset() {
|
||||
*x = RetrieveRequest{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_light_light_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RetrieveRequest) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RetrieveRequest) ProtoMessage() {}
|
||||
|
||||
func (x *RetrieveRequest) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_light_light_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RetrieveRequest.ProtoReflect.Descriptor instead.
|
||||
func (*RetrieveRequest) Descriptor() ([]byte, []int) {
|
||||
return file_light_light_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *RetrieveRequest) GetBatchHeaderHash() []byte {
|
||||
if x != nil {
|
||||
return x.BatchHeaderHash
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *RetrieveRequest) GetBlobIndex() uint32 {
|
||||
if x != nil {
|
||||
return x.BlobIndex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type RetrieveReply struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Status bool `protobuf:"varint,1,opt,name=status,proto3" json:"status,omitempty"`
|
||||
Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
|
||||
}
|
||||
|
||||
func (x *RetrieveReply) Reset() {
|
||||
*x = RetrieveReply{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_light_light_proto_msgTypes[3]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *RetrieveReply) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*RetrieveReply) ProtoMessage() {}
|
||||
|
||||
func (x *RetrieveReply) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_light_light_proto_msgTypes[3]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use RetrieveReply.ProtoReflect.Descriptor instead.
|
||||
func (*RetrieveReply) Descriptor() ([]byte, []int) {
|
||||
return file_light_light_proto_rawDescGZIP(), []int{3}
|
||||
}
|
||||
|
||||
func (x *RetrieveReply) GetStatus() bool {
|
||||
if x != nil {
|
||||
return x.Status
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *RetrieveReply) GetData() []byte {
|
||||
if x != nil {
|
||||
return x.Data
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_light_light_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_light_light_proto_rawDesc = []byte{
|
||||
0x0a, 0x11, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e, 0x70, 0x72,
|
||||
0x6f, 0x74, 0x6f, 0x12, 0x05, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x22, 0x8d, 0x01, 0x0a, 0x0d, 0x53,
|
||||
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09,
|
||||
0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52,
|
||||
0x08, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d, 0x49, 0x64, 0x12, 0x2a, 0x0a, 0x11, 0x62, 0x61, 0x74,
|
||||
0x63, 0x68, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x02,
|
||||
0x20, 0x01, 0x28, 0x0c, 0x52, 0x0f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65,
|
||||
0x72, 0x48, 0x61, 0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x69, 0x6e,
|
||||
0x64, 0x65, 0x78, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x62, 0x49,
|
||||
0x6e, 0x64, 0x65, 0x78, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x18, 0x04, 0x20,
|
||||
0x01, 0x28, 0x0d, 0x52, 0x05, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x22, 0x27, 0x0a, 0x0b, 0x53, 0x61,
|
||||
0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x73, 0x75, 0x63,
|
||||
0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x73, 0x75, 0x63, 0x63,
|
||||
0x65, 0x73, 0x73, 0x22, 0x5c, 0x0a, 0x0f, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x52,
|
||||
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x2a, 0x0a, 0x11, 0x62, 0x61, 0x74, 0x63, 0x68, 0x5f,
|
||||
0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x0c, 0x52, 0x0f, 0x62, 0x61, 0x74, 0x63, 0x68, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x48, 0x61,
|
||||
0x73, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x62, 0x6c, 0x6f, 0x62, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x62, 0x6c, 0x6f, 0x62, 0x49, 0x6e, 0x64, 0x65,
|
||||
0x78, 0x22, 0x3b, 0x0a, 0x0d, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x52, 0x65, 0x70,
|
||||
0x6c, 0x79, 0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x08, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61,
|
||||
0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x32, 0x79,
|
||||
0x0a, 0x05, 0x4c, 0x69, 0x67, 0x68, 0x74, 0x12, 0x34, 0x0a, 0x06, 0x53, 0x61, 0x6d, 0x70, 0x6c,
|
||||
0x65, 0x12, 0x14, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e, 0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65,
|
||||
0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x12, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e,
|
||||
0x53, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3a, 0x0a,
|
||||
0x08, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x12, 0x16, 0x2e, 0x6c, 0x69, 0x67, 0x68,
|
||||
0x74, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65, 0x76, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
|
||||
0x74, 0x1a, 0x14, 0x2e, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x2e, 0x52, 0x65, 0x74, 0x72, 0x69, 0x65,
|
||||
0x76, 0x65, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x30, 0x5a, 0x2e, 0x67, 0x69, 0x74,
|
||||
0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x30, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x30,
|
||||
0x67, 0x2d, 0x64, 0x61, 0x74, 0x61, 0x2d, 0x61, 0x76, 0x61, 0x69, 0x6c, 0x2f, 0x72, 0x75, 0x6e,
|
||||
0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x62, 0x06, 0x70, 0x72, 0x6f,
|
||||
0x74, 0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_light_light_proto_rawDescOnce sync.Once
|
||||
file_light_light_proto_rawDescData = file_light_light_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_light_light_proto_rawDescGZIP() []byte {
|
||||
file_light_light_proto_rawDescOnce.Do(func() {
|
||||
file_light_light_proto_rawDescData = protoimpl.X.CompressGZIP(file_light_light_proto_rawDescData)
|
||||
})
|
||||
return file_light_light_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_light_light_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
||||
var file_light_light_proto_goTypes = []interface{}{
|
||||
(*SampleRequest)(nil), // 0: light.SampleRequest
|
||||
(*SampleReply)(nil), // 1: light.SampleReply
|
||||
(*RetrieveRequest)(nil), // 2: light.RetrieveRequest
|
||||
(*RetrieveReply)(nil), // 3: light.RetrieveReply
|
||||
}
|
||||
var file_light_light_proto_depIdxs = []int32{
|
||||
0, // 0: light.Light.Sample:input_type -> light.SampleRequest
|
||||
2, // 1: light.Light.Retrieve:input_type -> light.RetrieveRequest
|
||||
1, // 2: light.Light.Sample:output_type -> light.SampleReply
|
||||
3, // 3: light.Light.Retrieve:output_type -> light.RetrieveReply
|
||||
2, // [2:4] is the sub-list for method output_type
|
||||
0, // [0:2] is the sub-list for method input_type
|
||||
0, // [0:0] is the sub-list for extension type_name
|
||||
0, // [0:0] is the sub-list for extension extendee
|
||||
0, // [0:0] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_light_light_proto_init() }
|
||||
func file_light_light_proto_init() {
|
||||
if File_light_light_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_light_light_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SampleRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_light_light_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*SampleReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_light_light_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RetrieveRequest); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_light_light_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*RetrieveReply); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_light_light_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 4,
|
||||
NumExtensions: 0,
|
||||
NumServices: 1,
|
||||
},
|
||||
GoTypes: file_light_light_proto_goTypes,
|
||||
DependencyIndexes: file_light_light_proto_depIdxs,
|
||||
MessageInfos: file_light_light_proto_msgTypes,
|
||||
}.Build()
|
||||
File_light_light_proto = out.File
|
||||
file_light_light_proto_rawDesc = nil
|
||||
file_light_light_proto_goTypes = nil
|
||||
file_light_light_proto_depIdxs = nil
|
||||
}
|
@ -1,141 +0,0 @@
|
||||
// Code generated by protoc-gen-go-grpc. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-grpc v1.2.0
|
||||
// - protoc v4.25.3
|
||||
// source: light/light.proto
|
||||
|
||||
package light
|
||||
|
||||
import (
|
||||
context "context"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
// Requires gRPC-Go v1.32.0 or later.
|
||||
const _ = grpc.SupportPackageIsVersion7
|
||||
|
||||
// LightClient is the client API for Light service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type LightClient interface {
|
||||
Sample(ctx context.Context, in *SampleRequest, opts ...grpc.CallOption) (*SampleReply, error)
|
||||
Retrieve(ctx context.Context, in *RetrieveRequest, opts ...grpc.CallOption) (*RetrieveReply, error)
|
||||
}
|
||||
|
||||
type lightClient struct {
|
||||
cc grpc.ClientConnInterface
|
||||
}
|
||||
|
||||
func NewLightClient(cc grpc.ClientConnInterface) LightClient {
|
||||
return &lightClient{cc}
|
||||
}
|
||||
|
||||
func (c *lightClient) Sample(ctx context.Context, in *SampleRequest, opts ...grpc.CallOption) (*SampleReply, error) {
|
||||
out := new(SampleReply)
|
||||
err := c.cc.Invoke(ctx, "/light.Light/Sample", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *lightClient) Retrieve(ctx context.Context, in *RetrieveRequest, opts ...grpc.CallOption) (*RetrieveReply, error) {
|
||||
out := new(RetrieveReply)
|
||||
err := c.cc.Invoke(ctx, "/light.Light/Retrieve", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// LightServer is the server API for Light service.
|
||||
// All implementations must embed UnimplementedLightServer
|
||||
// for forward compatibility
|
||||
type LightServer interface {
|
||||
Sample(context.Context, *SampleRequest) (*SampleReply, error)
|
||||
Retrieve(context.Context, *RetrieveRequest) (*RetrieveReply, error)
|
||||
mustEmbedUnimplementedLightServer()
|
||||
}
|
||||
|
||||
// UnimplementedLightServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedLightServer struct {
|
||||
}
|
||||
|
||||
func (UnimplementedLightServer) Sample(context.Context, *SampleRequest) (*SampleReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Sample not implemented")
|
||||
}
|
||||
func (UnimplementedLightServer) Retrieve(context.Context, *RetrieveRequest) (*RetrieveReply, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Retrieve not implemented")
|
||||
}
|
||||
func (UnimplementedLightServer) mustEmbedUnimplementedLightServer() {}
|
||||
|
||||
// UnsafeLightServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to LightServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeLightServer interface {
|
||||
mustEmbedUnimplementedLightServer()
|
||||
}
|
||||
|
||||
func RegisterLightServer(s grpc.ServiceRegistrar, srv LightServer) {
|
||||
s.RegisterService(&Light_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Light_Sample_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SampleRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LightServer).Sample(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/light.Light/Sample",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LightServer).Sample(ctx, req.(*SampleRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Light_Retrieve_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(RetrieveRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(LightServer).Retrieve(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/light.Light/Retrieve",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(LightServer).Retrieve(ctx, req.(*RetrieveRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Light_ServiceDesc is the grpc.ServiceDesc for Light service.
|
||||
// It's only intended for direct use with grpc.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Light_ServiceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "light.Light",
|
||||
HandlerType: (*LightServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "Sample",
|
||||
Handler: _Light_Sample_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Retrieve",
|
||||
Handler: _Light_Retrieve_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "light/light.proto",
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/url"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/helper/da/service"
|
||||
"github.com/0glabs/0g-chain/helper/da/types"
|
||||
|
||||
"github.com/lesismal/nbio/nbhttp"
|
||||
"github.com/lesismal/nbio/nbhttp/websocket"
|
||||
)
|
||||
|
||||
const (
|
||||
subscribeMsg = "{\"jsonrpc\":\"2.0\",\"method\":\"subscribe\",\"id\":1,\"params\":{\"query\":\"tm.event='Tx'\"}}"
|
||||
)
|
||||
|
||||
var (
|
||||
rpcAddress = flag.String("rpc-address", "34.214.2.28:32001", "address of da-light rpc server")
|
||||
wsAddress = flag.String("ws-address", "127.0.0.1:26657", "address of emvos ws server")
|
||||
relativePath = flag.String("relative-path", "", "relative path of evmosd")
|
||||
account = flag.String("account", "", "account to run evmosd cli")
|
||||
keyring = flag.String("keyring", "", "keyring to run evmosd cli")
|
||||
homePath = flag.String("home", "", "home path of evmosd node")
|
||||
)
|
||||
|
||||
func newUpgrader() *websocket.Upgrader {
|
||||
u := websocket.NewUpgrader()
|
||||
u.OnMessage(func(c *websocket.Conn, messageType websocket.MessageType, data []byte) {
|
||||
log.Println("onEcho:", string(data))
|
||||
ctx := context.WithValue(context.Background(), types.DA_RPC_ADDRESS, *rpcAddress)
|
||||
ctx = context.WithValue(ctx, types.NODE_CLI_RELATIVE_PATH, *relativePath)
|
||||
ctx = context.WithValue(ctx, types.NODE_CLI_EXEC_ACCOUNT, *account)
|
||||
ctx = context.WithValue(ctx, types.NODE_CLI_EXEC_KEYRING, *keyring)
|
||||
ctx = context.WithValue(ctx, types.NODE_HOME_PATH, *homePath)
|
||||
go func() { service.OnMessage(ctx, c, messageType, data) }()
|
||||
})
|
||||
|
||||
u.OnClose(func(c *websocket.Conn, err error) {
|
||||
fmt.Println("OnClose:", c.RemoteAddr().String(), err)
|
||||
service.OnClose()
|
||||
})
|
||||
|
||||
return u
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
engine := nbhttp.NewEngine(nbhttp.Config{})
|
||||
err := engine.Start()
|
||||
if err != nil {
|
||||
fmt.Printf("nbio.Start failed: %v\n", err)
|
||||
return
|
||||
}
|
||||
|
||||
go func() {
|
||||
u := url.URL{Scheme: "ws", Host: *wsAddress, Path: "/websocket"}
|
||||
dialer := &websocket.Dialer{
|
||||
Engine: engine,
|
||||
Upgrader: newUpgrader(),
|
||||
DialTimeout: time.Second * 3,
|
||||
}
|
||||
c, res, err := dialer.Dial(u.String(), nil)
|
||||
if err != nil {
|
||||
if res != nil && res.Body != nil {
|
||||
bReason, _ := io.ReadAll(res.Body)
|
||||
fmt.Printf("dial failed: %v, reason: %v\n", err, string(bReason))
|
||||
} else {
|
||||
fmt.Printf("dial failed: %v\n", err)
|
||||
}
|
||||
return
|
||||
}
|
||||
c.WriteMessage(websocket.TextMessage, []byte(subscribeMsg))
|
||||
}()
|
||||
|
||||
interrupt := make(chan os.Signal, 1)
|
||||
signal.Notify(interrupt, os.Interrupt)
|
||||
<-interrupt
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
engine.Shutdown(ctx)
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package light;
|
||||
|
||||
option go_package = "proto/light";
|
||||
|
||||
service Light {
|
||||
rpc Sample(SampleRequest) returns (SampleReply) {}
|
||||
rpc Retrieve(RetrieveRequest) returns (RetrieveReply) {}
|
||||
}
|
||||
|
||||
// SampleRequest contains the blob to sample (by batch and blob index) and required sample times
|
||||
message SampleRequest {
|
||||
bytes stream_id = 1;
|
||||
bytes batch_header_hash = 2;
|
||||
uint32 blob_index = 3;
|
||||
uint32 times = 4;
|
||||
}
|
||||
|
||||
// SampleReply contains the sample result
|
||||
message SampleReply {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
message RetrieveRequest {
|
||||
bytes batch_header_hash = 1;
|
||||
uint32 blob_index = 2;
|
||||
}
|
||||
|
||||
message RetrieveReply {
|
||||
bool status = 1;
|
||||
bytes data = 2;
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/0glabs/0g-chain/helper/da/client"
|
||||
"github.com/0glabs/0g-chain/helper/da/types"
|
||||
"github.com/0glabs/0g-chain/helper/da/utils/sizedw8grp"
|
||||
|
||||
jsoniter "github.com/json-iterator/go"
|
||||
"github.com/lesismal/nbio/nbhttp/websocket"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rs/zerolog/log"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultClientInstance = 10
|
||||
)
|
||||
|
||||
var rpcClient client.DaLightRpcClient
|
||||
|
||||
func OnMessage(ctx context.Context, c *websocket.Conn, messageType websocket.MessageType, data []byte) {
|
||||
if messageType == websocket.TextMessage {
|
||||
rawMsg := unwrapJsonRpc(data)
|
||||
if verifyQuery(rawMsg) {
|
||||
eventStr := jsoniter.Get(rawMsg, "events").ToString()
|
||||
events := map[string][]string{}
|
||||
if err := jsoniter.UnmarshalFromString(eventStr, &events); err == nil {
|
||||
dasRequestMap := make(map[string]string, 4)
|
||||
for key, val := range events {
|
||||
if strings.HasPrefix(key, "das_request.") {
|
||||
dasRequestMap[strings.ReplaceAll(key, "das_request.", "")] = val[0]
|
||||
}
|
||||
}
|
||||
if len(dasRequestMap) == 4 {
|
||||
rid, _ := strconv.ParseUint(dasRequestMap["request_id"], 10, 64)
|
||||
numBlobs, _ := strconv.ParseUint(dasRequestMap["num_blobs"], 10, 64)
|
||||
req := types.DASRequest{
|
||||
RequestId: rid,
|
||||
StreamId: dasRequestMap["stream_id"],
|
||||
BatchHeaderHash: dasRequestMap["batch_header_hash"],
|
||||
NumBlobs: numBlobs,
|
||||
}
|
||||
err := handleDasRequest(ctx, req)
|
||||
|
||||
if err != nil {
|
||||
log.Err(err).Msgf("failed to handle das request: %v, %v", req, err)
|
||||
} else {
|
||||
log.Info().Msgf("successfully handled das request: %v", req)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO: handle other message
|
||||
}
|
||||
}
|
||||
|
||||
func OnClose() {
|
||||
if rpcClient != nil {
|
||||
rpcClient.Destroy()
|
||||
rpcClient = nil
|
||||
}
|
||||
}
|
||||
|
||||
func unwrapJsonRpc(data []byte) []byte {
|
||||
result := jsoniter.Get(data, "result")
|
||||
if 0 < len(result.Keys()) {
|
||||
return []byte(result.ToString())
|
||||
}
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
func verifyQuery(data []byte) bool {
|
||||
if len(data) > 0 {
|
||||
return jsoniter.Get(data, "query").ToString() == "tm.event='Tx'"
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func min(a, b int) int {
|
||||
if a < b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func handleDasRequest(ctx context.Context, request types.DASRequest) error {
|
||||
if rpcClient == nil {
|
||||
addrVal := ctx.Value(types.DA_RPC_ADDRESS)
|
||||
if addrVal == nil {
|
||||
return errors.New("da light service address not found in context")
|
||||
}
|
||||
|
||||
limit := ctx.Value(types.INSTANCE_LIMIT)
|
||||
if limit == nil {
|
||||
limit = defaultClientInstance
|
||||
}
|
||||
|
||||
rpcClient = client.NewDaLightClient(addrVal.(string), limit.(int))
|
||||
}
|
||||
|
||||
streamID, err := hex.DecodeString(request.StreamId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
batchHeaderHash, err := hex.DecodeString(request.BatchHeaderHash)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result := make(chan bool, request.NumBlobs)
|
||||
taskCnt := min(rpcClient.GetInstanceCount(), int(request.NumBlobs))
|
||||
wg := sizedw8grp.New(taskCnt)
|
||||
|
||||
for i := uint64(0); i < request.NumBlobs; i++ {
|
||||
wg.Add()
|
||||
go func(idx uint64) {
|
||||
defer wg.Done()
|
||||
ret, err := rpcClient.Sample(ctx, streamID, batchHeaderHash, uint32(idx), 1)
|
||||
if err != nil {
|
||||
log.Err(err).Msgf("failed to sample data availability with blob index %d", idx)
|
||||
result <- false
|
||||
} else {
|
||||
log.Info().Msgf("sample result for blob index %d: %v", idx, ret)
|
||||
result <- ret
|
||||
}
|
||||
}(i)
|
||||
}
|
||||
wg.Wait()
|
||||
close(result)
|
||||
|
||||
finalResult := true
|
||||
for val := range result {
|
||||
if !val {
|
||||
finalResult = false
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
return runEvmosdCliReportDasResult(ctx, request.RequestId, finalResult)
|
||||
}
|
||||
|
||||
func runEvmosdCliReportDasResult(ctx context.Context, requestId uint64, result bool) error {
|
||||
relativePath := ctx.Value(types.NODE_CLI_RELATIVE_PATH)
|
||||
if relativePath == nil {
|
||||
return errors.New("relativePath not found in context")
|
||||
}
|
||||
|
||||
account := ctx.Value(types.NODE_CLI_EXEC_ACCOUNT)
|
||||
if account == nil {
|
||||
return errors.New("account not found in context")
|
||||
}
|
||||
|
||||
args := []string{
|
||||
"tx",
|
||||
"das",
|
||||
"report-das-result",
|
||||
strconv.FormatUint(requestId, 10),
|
||||
strconv.FormatBool(result),
|
||||
"--from", account.(string),
|
||||
"--gas-prices", "7678500neuron", // TODO: use args to set gas prices
|
||||
}
|
||||
|
||||
homePath := ctx.Value(types.NODE_HOME_PATH)
|
||||
if len(homePath.(string)) > 0 {
|
||||
args = append(args, "--home", homePath.(string))
|
||||
}
|
||||
|
||||
keyring := ctx.Value(types.NODE_CLI_EXEC_KEYRING)
|
||||
if len(keyring.(string)) > 0 {
|
||||
args = append(args, "--keyring-backend", keyring.(string))
|
||||
}
|
||||
|
||||
cmdStr := relativePath.(string) + "0gchaind"
|
||||
cmd := exec.Command(cmdStr, append(args, "-y")...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
return cmd.Run()
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package types
|
||||
|
||||
type DASRequest struct {
|
||||
RequestId uint64 `json:"request_id"`
|
||||
StreamId string `json:"stream_id"`
|
||||
BatchHeaderHash string `json:"batch_header_hash"`
|
||||
NumBlobs uint64 `json:"num_blobs"`
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
DA_RPC_ADDRESS = "rpc_address"
|
||||
INSTANCE_LIMIT = "instance_limit"
|
||||
NODE_CLI_RELATIVE_PATH = "relative_path"
|
||||
NODE_CLI_EXEC_ACCOUNT = "node_exec_account"
|
||||
NODE_CLI_EXEC_KEYRING = "node_exec_keyring"
|
||||
NODE_HOME_PATH = "home_path"
|
||||
)
|
@ -1,51 +0,0 @@
|
||||
package sizedw8grp
|
||||
|
||||
import (
|
||||
"context"
|
||||
"math"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type SizedWaitGroup struct {
|
||||
Size int
|
||||
|
||||
current chan struct{}
|
||||
wg sync.WaitGroup
|
||||
}
|
||||
|
||||
func New(limit int) SizedWaitGroup {
|
||||
size := math.MaxInt32
|
||||
if limit > 0 {
|
||||
size = limit
|
||||
}
|
||||
return SizedWaitGroup{
|
||||
Size: size,
|
||||
|
||||
current: make(chan struct{}, size),
|
||||
wg: sync.WaitGroup{},
|
||||
}
|
||||
}
|
||||
|
||||
func (s *SizedWaitGroup) Add() {
|
||||
_ = s.AddWithContext(context.Background())
|
||||
}
|
||||
|
||||
func (s *SizedWaitGroup) AddWithContext(ctx context.Context) error {
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
case s.current <- struct{}{}:
|
||||
break
|
||||
}
|
||||
s.wg.Add(1)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *SizedWaitGroup) Done() {
|
||||
<-s.current
|
||||
s.wg.Done()
|
||||
}
|
||||
|
||||
func (s *SizedWaitGroup) Wait() {
|
||||
s.wg.Wait()
|
||||
}
|
@ -24,7 +24,9 @@ DATA=~/.0gchain
|
||||
# remove any old state and config
|
||||
rm -rf $DATA
|
||||
|
||||
BINARY=0gchaind
|
||||
OS_FAMILY=$(uname -s)
|
||||
NATIVE_GO_OS=$(echo $OS_FAMILY | tr '[:upper:]' '[:lower:]')
|
||||
BINARY=./out/$NATIVE_GO_OS/0gchaind
|
||||
|
||||
# Create new data directory, overwriting any that alread existed
|
||||
chainID="zgchain_8888-1"
|
||||
@ -48,12 +50,12 @@ $BINARY config keyring-backend test
|
||||
|
||||
# Create validator keys and add account to genesis
|
||||
validatorKeyName="validator"
|
||||
printf "$validatorMnemonic\n" | $BINARY keys add $validatorKeyName --recover
|
||||
printf "$validatorMnemonic\n" | $BINARY keys add $validatorKeyName --eth --recover
|
||||
$BINARY add-genesis-account $validatorKeyName 2000000000000000000000ua0gi
|
||||
|
||||
# Create faucet keys and add account to genesis
|
||||
faucetKeyName="faucet"
|
||||
printf "$faucetMnemonic\n" | $BINARY keys add $faucetKeyName --recover
|
||||
printf "$faucetMnemonic\n" | $BINARY keys add $faucetKeyName --eth --recover
|
||||
$BINARY add-genesis-account $faucetKeyName 1000000000000000000000ua0gi
|
||||
|
||||
evmFaucetKeyName="evm-faucet"
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"time"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
|
||||
@ -41,7 +42,7 @@ func TestResetPeriodVestingAccount_NoVestingPeriods(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -64,7 +65,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vested(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -97,7 +98,7 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_Vesting(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
@ -125,25 +126,25 @@ func TestResetPeriodVestingAccount_SingleVestingPeriod_ExactStartTime(t *testing
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(4e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(4e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // -15 days - vested
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +15 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +30 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
@ -159,36 +160,36 @@ func TestResetPeriodVestingAccount_MultiplePeriods(t *testing.T) {
|
||||
expectedPeriods := []vestingtypes.Period{
|
||||
{
|
||||
Length: 15 * 24 * 60 * 60, // 15 days
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
{
|
||||
Length: 15 * 24 * 60 * 60, // 15 days
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(2e6))), vacc.OriginalVesting, "expected original vesting to be updated")
|
||||
assert.Equal(t, newVestingStartTime.Unix(), vacc.StartTime, "expected vesting start time to be updated")
|
||||
assert.Equal(t, expectedEndtime, vacc.EndTime, "expected vesting end time end at last period")
|
||||
assert.Equal(t, expectedPeriods, vacc.VestingPeriods, "expected vesting periods to be updated")
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(3e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(3e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // -15 days - vested
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +15 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
@ -198,35 +199,35 @@ func TestResetPeriodVestingAccount_DelegatedVesting_GreaterThanVesting(t *testin
|
||||
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
|
||||
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
|
||||
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(2e6))), vacc.DelegatedFree, "expected delegated free to be updated")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be updated")
|
||||
}
|
||||
|
||||
func TestResetPeriodVestingAccount_DelegatedVesting_LessThanVested(t *testing.T) {
|
||||
balance := sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(3e6)))
|
||||
balance := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(3e6)))
|
||||
vestingStartTime := time.Now().Add(-30 * 24 * time.Hour) // 30 days in past
|
||||
|
||||
periods := vestingtypes.Periods{
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // -15 days - vested
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // 0 days - exact on the start time
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
vestingtypes.Period{
|
||||
Length: 15 * 24 * 60 * 60, // +15 days - vesting
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))),
|
||||
Amount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))),
|
||||
},
|
||||
}
|
||||
|
||||
vacc := createVestingAccount(balance, vestingStartTime, periods)
|
||||
vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))))
|
||||
vacc.TrackDelegation(vestingStartTime, balance, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))))
|
||||
|
||||
newVestingStartTime := vestingStartTime.Add(30 * 24 * time.Hour)
|
||||
ResetPeriodicVestingAccount(vacc, newVestingStartTime)
|
||||
|
||||
assert.Equal(t, sdk.Coins(nil), vacc.DelegatedFree, "expected delegrated free to be unmodified")
|
||||
assert.Equal(t, sdk.NewCoins(sdk.NewCoin("ua0gi", sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified")
|
||||
assert.Equal(t, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(sdkmath.NewInt(1e6))), vacc.DelegatedVesting, "expected delegated vesting to be unmodified")
|
||||
}
|
||||
|
6
precompiles/common/errors.go
Normal file
6
precompiles/common/errors.go
Normal file
@ -0,0 +1,6 @@
|
||||
package common
|
||||
|
||||
const (
|
||||
ErrGetStateDB = "get EVM StateDB failed"
|
||||
ErrInvalidNumberOfArgs = "invalid number of arguments; expected %d; got: %d"
|
||||
)
|
428
precompiles/dasigners/IDASigners.abi
Normal file
428
precompiles/dasigners/IDASigners.abi
Normal file
@ -0,0 +1,428 @@
|
||||
[
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"indexed": false,
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "pkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "X",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "Y",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"indexed": false,
|
||||
"internalType": "struct BN254.G2Point",
|
||||
"name": "pkG2",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "NewSigner",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"anonymous": false,
|
||||
"inputs": [
|
||||
{
|
||||
"indexed": true,
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"indexed": false,
|
||||
"internalType": "string",
|
||||
"name": "socket",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "SocketUpdated",
|
||||
"type": "event"
|
||||
},
|
||||
{
|
||||
"inputs": [],
|
||||
"name": "epochNumber",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_quorumId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "bytes",
|
||||
"name": "_quorumBitmap",
|
||||
"type": "bytes"
|
||||
}
|
||||
],
|
||||
"name": "getAggPkG1",
|
||||
"outputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "aggPkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "total",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "hit",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_quorumId",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "getQuorum",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address[]",
|
||||
"name": "",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_quorumId",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint32",
|
||||
"name": "_rowIndex",
|
||||
"type": "uint32"
|
||||
}
|
||||
],
|
||||
"name": "getQuorumRow",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address[]",
|
||||
"name": "_account",
|
||||
"type": "address[]"
|
||||
}
|
||||
],
|
||||
"name": "getSigner",
|
||||
"outputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "socket",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "pkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "X",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "Y",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G2Point",
|
||||
"name": "pkG2",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"internalType": "struct IDASigners.SignerDetail[]",
|
||||
"name": "",
|
||||
"type": "tuple[]"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_account",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "isSigner",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "quorumCount",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "_signature",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "registerNextEpoch",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "signer",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "socket",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "pkG1",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "X",
|
||||
"type": "uint256[2]"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256[2]",
|
||||
"name": "Y",
|
||||
"type": "uint256[2]"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G2Point",
|
||||
"name": "pkG2",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"internalType": "struct IDASigners.SignerDetail",
|
||||
"name": "_signer",
|
||||
"type": "tuple"
|
||||
},
|
||||
{
|
||||
"components": [
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "X",
|
||||
"type": "uint256"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "Y",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"internalType": "struct BN254.G1Point",
|
||||
"name": "_signature",
|
||||
"type": "tuple"
|
||||
}
|
||||
],
|
||||
"name": "registerSigner",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "_account",
|
||||
"type": "address"
|
||||
},
|
||||
{
|
||||
"internalType": "uint256",
|
||||
"name": "_epoch",
|
||||
"type": "uint256"
|
||||
}
|
||||
],
|
||||
"name": "registeredEpoch",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "bool",
|
||||
"name": "",
|
||||
"type": "bool"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
{
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "string",
|
||||
"name": "_socket",
|
||||
"type": "string"
|
||||
}
|
||||
],
|
||||
"name": "updateSocket",
|
||||
"outputs": [],
|
||||
"stateMutability": "nonpayable",
|
||||
"type": "function"
|
||||
}
|
||||
]
|
801
precompiles/dasigners/contract.go
Normal file
801
precompiles/dasigners/contract.go
Normal file
File diff suppressed because one or more lines are too long
155
precompiles/dasigners/dasigners.go
Normal file
155
precompiles/dasigners/dasigners.go
Normal file
@ -0,0 +1,155 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
precopmiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
dasignerskeeper "github.com/0glabs/0g-chain/x/dasigners/v1/keeper"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
)
|
||||
|
||||
const (
|
||||
PrecompileAddress = "0x0000000000000000000000000000000000001000"
|
||||
|
||||
RequiredGasMax uint64 = 1000_000_000
|
||||
|
||||
DASignersFunctionEpochNumber = "epochNumber"
|
||||
DASignersFunctionQuorumCount = "quorumCount"
|
||||
DASignersFunctionGetSigner = "getSigner"
|
||||
DASignersFunctionGetQuorum = "getQuorum"
|
||||
DASignersFunctionGetQuorumRow = "getQuorumRow"
|
||||
DASignersFunctionRegisterSigner = "registerSigner"
|
||||
DASignersFunctionUpdateSocket = "updateSocket"
|
||||
DASignersFunctionRegisterNextEpoch = "registerNextEpoch"
|
||||
DASignersFunctionGetAggPkG1 = "getAggPkG1"
|
||||
DASignersFunctionIsSigner = "isSigner"
|
||||
DASignersFunctionRegisteredEpoch = "registeredEpoch"
|
||||
)
|
||||
|
||||
var RequiredGasBasic = map[string]uint64{
|
||||
DASignersFunctionEpochNumber: 1000,
|
||||
DASignersFunctionQuorumCount: 1000,
|
||||
DASignersFunctionGetSigner: 100000,
|
||||
DASignersFunctionGetQuorum: 100000,
|
||||
DASignersFunctionGetQuorumRow: 10000,
|
||||
DASignersFunctionRegisterSigner: 100000,
|
||||
DASignersFunctionUpdateSocket: 50000,
|
||||
DASignersFunctionRegisterNextEpoch: 100000,
|
||||
DASignersFunctionGetAggPkG1: 1000000,
|
||||
DASignersFunctionIsSigner: 10000,
|
||||
DASignersFunctionRegisteredEpoch: 10000,
|
||||
}
|
||||
|
||||
var KVGasConfig storetypes.GasConfig = storetypes.GasConfig{
|
||||
HasCost: 0,
|
||||
DeleteCost: 0,
|
||||
ReadCostFlat: 0,
|
||||
ReadCostPerByte: 0,
|
||||
WriteCostFlat: 0,
|
||||
WriteCostPerByte: 0,
|
||||
IterNextCostFlat: 0,
|
||||
}
|
||||
|
||||
var _ vm.PrecompiledContract = &DASignersPrecompile{}
|
||||
|
||||
type DASignersPrecompile struct {
|
||||
abi abi.ABI
|
||||
dasignersKeeper dasignerskeeper.Keeper
|
||||
}
|
||||
|
||||
func NewDASignersPrecompile(dasignersKeeper dasignerskeeper.Keeper) (*DASignersPrecompile, error) {
|
||||
abi, err := abi.JSON(strings.NewReader(DASignersABI))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &DASignersPrecompile{
|
||||
abi: abi,
|
||||
dasignersKeeper: dasignersKeeper,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Address implements vm.PrecompiledContract.
|
||||
func (d *DASignersPrecompile) Address() common.Address {
|
||||
return common.HexToAddress(PrecompileAddress)
|
||||
}
|
||||
|
||||
// RequiredGas implements vm.PrecompiledContract.
|
||||
func (d *DASignersPrecompile) RequiredGas(input []byte) uint64 {
|
||||
method, err := d.abi.MethodById(input[:4])
|
||||
if err != nil {
|
||||
return RequiredGasMax
|
||||
}
|
||||
if gas, ok := RequiredGasBasic[method.Name]; ok {
|
||||
return gas
|
||||
}
|
||||
return RequiredGasMax
|
||||
}
|
||||
|
||||
// Run implements vm.PrecompiledContract.
|
||||
func (d *DASignersPrecompile) Run(evm *vm.EVM, contract *vm.Contract, readonly bool) ([]byte, error) {
|
||||
// parse input
|
||||
if len(contract.Input) < 4 {
|
||||
return nil, vm.ErrExecutionReverted
|
||||
}
|
||||
method, err := d.abi.MethodById(contract.Input[:4])
|
||||
if err != nil {
|
||||
return nil, vm.ErrExecutionReverted
|
||||
}
|
||||
args, err := method.Inputs.Unpack(contract.Input[4:])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// get state db and context
|
||||
stateDB, ok := evm.StateDB.(*statedb.StateDB)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrGetStateDB)
|
||||
}
|
||||
ctx := stateDB.GetContext()
|
||||
// reset gas config
|
||||
ctx = ctx.WithKVGasConfig(KVGasConfig)
|
||||
initialGas := ctx.GasMeter().GasConsumed()
|
||||
|
||||
var bz []byte
|
||||
switch method.Name {
|
||||
// queries
|
||||
case DASignersFunctionEpochNumber:
|
||||
bz, err = d.EpochNumber(ctx, evm, method, args)
|
||||
case DASignersFunctionQuorumCount:
|
||||
bz, err = d.QuorumCount(ctx, evm, method, args)
|
||||
case DASignersFunctionGetSigner:
|
||||
bz, err = d.GetSigner(ctx, evm, method, args)
|
||||
case DASignersFunctionGetQuorum:
|
||||
bz, err = d.GetQuorum(ctx, evm, method, args)
|
||||
case DASignersFunctionGetQuorumRow:
|
||||
bz, err = d.GetQuorumRow(ctx, evm, method, args)
|
||||
case DASignersFunctionGetAggPkG1:
|
||||
bz, err = d.GetAggPkG1(ctx, evm, method, args)
|
||||
case DASignersFunctionIsSigner:
|
||||
bz, err = d.IsSigner(ctx, evm, method, args)
|
||||
case DASignersFunctionRegisteredEpoch:
|
||||
bz, err = d.RegisteredEpoch(ctx, evm, method, args)
|
||||
// txs
|
||||
case DASignersFunctionRegisterSigner:
|
||||
bz, err = d.RegisterSigner(ctx, evm, stateDB, method, args)
|
||||
case DASignersFunctionRegisterNextEpoch:
|
||||
bz, err = d.RegisterNextEpoch(ctx, evm, stateDB, method, args)
|
||||
case DASignersFunctionUpdateSocket:
|
||||
bz, err = d.UpdateSocket(ctx, evm, stateDB, method, args)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
cost := ctx.GasMeter().GasConsumed() - initialGas
|
||||
|
||||
if !contract.UseGas(cost) {
|
||||
return nil, vm.ErrOutOfGas
|
||||
}
|
||||
return bz, nil
|
||||
}
|
5
precompiles/dasigners/errors.go
Normal file
5
precompiles/dasigners/errors.go
Normal file
@ -0,0 +1,5 @@
|
||||
package dasigners
|
||||
|
||||
const (
|
||||
ErrInvalidSender = "sender address %s is not the same as signer address %s"
|
||||
)
|
60
precompiles/dasigners/events.go
Normal file
60
precompiles/dasigners/events.go
Normal file
@ -0,0 +1,60 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
)
|
||||
|
||||
const (
|
||||
NewSignerEvent = "NewSigner"
|
||||
SocketUpdatedEvent = "SocketUpdated"
|
||||
)
|
||||
|
||||
func (d *DASignersPrecompile) EmitNewSignerEvent(ctx sdk.Context, stateDB *statedb.StateDB, signer IDASignersSignerDetail) error {
|
||||
event := d.abi.Events[NewSignerEvent]
|
||||
quries := make([]interface{}, 2)
|
||||
quries[0] = event.ID
|
||||
quries[1] = signer.Signer
|
||||
topics, err := abi.MakeTopics(quries)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
arguments := abi.Arguments{event.Inputs[1], event.Inputs[2]}
|
||||
b, err := arguments.Pack(signer.PkG1, signer.PkG2)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stateDB.AddLog(&types.Log{
|
||||
Address: d.Address(),
|
||||
Topics: topics[0],
|
||||
Data: b,
|
||||
BlockNumber: uint64(ctx.BlockHeight()),
|
||||
})
|
||||
return d.EmitSocketUpdatedEvent(ctx, stateDB, signer.Signer, signer.Socket)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) EmitSocketUpdatedEvent(ctx sdk.Context, stateDB *statedb.StateDB, signer common.Address, socket string) error {
|
||||
event := d.abi.Events[SocketUpdatedEvent]
|
||||
quries := make([]interface{}, 2)
|
||||
quries[0] = event.ID
|
||||
quries[1] = signer
|
||||
topics, err := abi.MakeTopics(quries)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
arguments := abi.Arguments{event.Inputs[1]}
|
||||
b, err := arguments.Pack(socket)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
stateDB.AddLog(&types.Log{
|
||||
Address: d.Address(),
|
||||
Topics: topics[0],
|
||||
Data: b,
|
||||
BlockNumber: uint64(ctx.BlockHeight()),
|
||||
})
|
||||
return nil
|
||||
}
|
113
precompiles/dasigners/query.go
Normal file
113
precompiles/dasigners/query.go
Normal file
@ -0,0 +1,113 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
precopmiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
)
|
||||
|
||||
func (d *DASignersPrecompile) EpochNumber(ctx sdk.Context, _ *vm.EVM, method *abi.Method, _ []interface{}) ([]byte, error) {
|
||||
epochNumber, err := d.dasignersKeeper.GetEpochNumber(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(big.NewInt(int64(epochNumber)))
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) QuorumCount(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryQuorumCountRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.QuorumCount(ctx, req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(big.NewInt(int64(response.QuorumCount)))
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetSigner(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQuerySignerRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.Signer(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signers := make([]IDASignersSignerDetail, len(response.Signer))
|
||||
for i, signer := range response.Signer {
|
||||
signers[i] = NewIDASignersSignerDetail(signer)
|
||||
}
|
||||
return method.Outputs.Pack(signers)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) IsSigner(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
account := ToLowerHexWithoutPrefix(args[0].(common.Address))
|
||||
_, found, err := d.dasignersKeeper.GetSigner(ctx, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(found)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) RegisteredEpoch(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
||||
}
|
||||
account := ToLowerHexWithoutPrefix(args[0].(common.Address))
|
||||
epoch := args[1].(*big.Int).Uint64()
|
||||
_, found, err := d.dasignersKeeper.GetRegistration(ctx, epoch, account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(found)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetQuorum(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryEpochQuorumRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.EpochQuorum(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signers := make([]common.Address, len(response.Quorum.Signers))
|
||||
for i, signer := range response.Quorum.Signers {
|
||||
signers[i] = common.HexToAddress(signer)
|
||||
}
|
||||
return method.Outputs.Pack(signers)
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetQuorumRow(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryEpochQuorumRowRequest(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.EpochQuorumRow(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(common.HexToAddress(response.Signer))
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) GetAggPkG1(ctx sdk.Context, _ *vm.EVM, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
req, err := NewQueryAggregatePubkeyG1Request(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
response, err := d.dasignersKeeper.AggregatePubkeyG1(sdk.WrapSDKContext(ctx), req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack(NewBN254G1Point(response.AggregatePubkeyG1), big.NewInt(int64(response.Total)), big.NewInt(int64(response.Hit)))
|
||||
}
|
64
precompiles/dasigners/tx.go
Normal file
64
precompiles/dasigners/tx.go
Normal file
@ -0,0 +1,64 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi"
|
||||
"github.com/ethereum/go-ethereum/core/vm"
|
||||
"github.com/evmos/ethermint/x/evm/statedb"
|
||||
)
|
||||
|
||||
func (d *DASignersPrecompile) RegisterSigner(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
msg, err := NewMsgRegisterSigner(args)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// validation
|
||||
sender := ToLowerHexWithoutPrefix(evm.Origin)
|
||||
if sender != msg.Signer.Account {
|
||||
return nil, fmt.Errorf(ErrInvalidSender, sender, msg.Signer.Account)
|
||||
}
|
||||
// execute
|
||||
_, err = d.dasignersKeeper.RegisterSigner(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// emit events
|
||||
err = d.EmitNewSignerEvent(ctx, stateDB, args[0].(IDASignersSignerDetail))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) RegisterNextEpoch(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
msg, err := NewMsgRegisterNextEpoch(args, ToLowerHexWithoutPrefix(evm.Origin))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// execute
|
||||
_, err = d.dasignersKeeper.RegisterNextEpoch(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
||||
|
||||
func (d *DASignersPrecompile) UpdateSocket(ctx sdk.Context, evm *vm.EVM, stateDB *statedb.StateDB, method *abi.Method, args []interface{}) ([]byte, error) {
|
||||
msg, err := NewMsgUpdateSocket(args, ToLowerHexWithoutPrefix(evm.Origin))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// execute
|
||||
_, err = d.dasignersKeeper.UpdateSocket(sdk.WrapSDKContext(ctx), msg)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// emit events
|
||||
err = d.EmitSocketUpdatedEvent(ctx, stateDB, evm.Origin, args[0].(string))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return method.Outputs.Pack()
|
||||
}
|
175
precompiles/dasigners/types.go
Normal file
175
precompiles/dasigners/types.go
Normal file
@ -0,0 +1,175 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/big"
|
||||
"strings"
|
||||
|
||||
precopmiles_common "github.com/0glabs/0g-chain/precompiles/common"
|
||||
dasignerstypes "github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
type BN254G1Point = struct {
|
||||
X *big.Int "json:\"X\""
|
||||
Y *big.Int "json:\"Y\""
|
||||
}
|
||||
|
||||
type BN254G2Point = struct {
|
||||
X [2]*big.Int "json:\"X\""
|
||||
Y [2]*big.Int "json:\"Y\""
|
||||
}
|
||||
|
||||
type IDASignersSignerDetail = struct {
|
||||
Signer common.Address "json:\"signer\""
|
||||
Socket string "json:\"socket\""
|
||||
PkG1 BN254G1Point "json:\"pkG1\""
|
||||
PkG2 BN254G2Point "json:\"pkG2\""
|
||||
}
|
||||
|
||||
func NewBN254G1Point(b []byte) BN254G1Point {
|
||||
return BN254G1Point{
|
||||
X: new(big.Int).SetBytes(b[:32]),
|
||||
Y: new(big.Int).SetBytes(b[32:64]),
|
||||
}
|
||||
}
|
||||
|
||||
func SerializeG1(p BN254G1Point) []byte {
|
||||
b := make([]byte, 0)
|
||||
b = append(b, common.LeftPadBytes(p.X.Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.Y.Bytes(), 32)...)
|
||||
return b
|
||||
}
|
||||
|
||||
func NewBN254G2Point(b []byte) BN254G2Point {
|
||||
return BN254G2Point{
|
||||
X: [2]*big.Int{
|
||||
new(big.Int).SetBytes(b[:32]),
|
||||
new(big.Int).SetBytes(b[32:64]),
|
||||
},
|
||||
Y: [2]*big.Int{
|
||||
new(big.Int).SetBytes(b[64:96]),
|
||||
new(big.Int).SetBytes(b[96:128]),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func SerializeG2(p BN254G2Point) []byte {
|
||||
b := make([]byte, 0)
|
||||
b = append(b, common.LeftPadBytes(p.X[0].Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.X[1].Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.Y[0].Bytes(), 32)...)
|
||||
b = append(b, common.LeftPadBytes(p.Y[1].Bytes(), 32)...)
|
||||
return b
|
||||
}
|
||||
|
||||
func NewQueryQuorumCountRequest(args []interface{}) (*dasignerstypes.QueryQuorumCountRequest, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryQuorumCountRequest{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewQuerySignerRequest(args []interface{}) (*dasignerstypes.QuerySignerRequest, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
accounts := args[0].([]common.Address)
|
||||
req := dasignerstypes.QuerySignerRequest{
|
||||
Accounts: make([]string, len(accounts)),
|
||||
}
|
||||
for i, account := range accounts {
|
||||
req.Accounts[i] = ToLowerHexWithoutPrefix(account)
|
||||
}
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
func NewQueryEpochQuorumRequest(args []interface{}) (*dasignerstypes.QueryEpochQuorumRequest, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryEpochQuorumRequest{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
QuorumId: args[1].(*big.Int).Uint64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewQueryEpochQuorumRowRequest(args []interface{}) (*dasignerstypes.QueryEpochQuorumRowRequest, error) {
|
||||
if len(args) != 3 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 3, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryEpochQuorumRowRequest{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
QuorumId: args[1].(*big.Int).Uint64(),
|
||||
RowIndex: args[2].(uint32),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewQueryAggregatePubkeyG1Request(args []interface{}) (*dasignerstypes.QueryAggregatePubkeyG1Request, error) {
|
||||
if len(args) != 3 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 3, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.QueryAggregatePubkeyG1Request{
|
||||
EpochNumber: args[0].(*big.Int).Uint64(),
|
||||
QuorumId: args[1].(*big.Int).Uint64(),
|
||||
QuorumBitmap: args[2].([]byte),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewIDASignersSignerDetail(signer *dasignerstypes.Signer) IDASignersSignerDetail {
|
||||
return IDASignersSignerDetail{
|
||||
Signer: common.HexToAddress(signer.Account),
|
||||
Socket: signer.Socket,
|
||||
PkG1: NewBN254G1Point(signer.PubkeyG1),
|
||||
PkG2: NewBN254G2Point(signer.PubkeyG2),
|
||||
}
|
||||
}
|
||||
|
||||
func ToLowerHexWithoutPrefix(addr common.Address) string {
|
||||
return strings.ToLower(addr.Hex()[2:])
|
||||
}
|
||||
|
||||
func NewMsgRegisterSigner(args []interface{}) (*dasignerstypes.MsgRegisterSigner, error) {
|
||||
if len(args) != 2 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 2, len(args))
|
||||
}
|
||||
|
||||
signer := args[0].(IDASignersSignerDetail)
|
||||
return &dasignerstypes.MsgRegisterSigner{
|
||||
Signer: &dasignerstypes.Signer{
|
||||
Account: ToLowerHexWithoutPrefix(signer.Signer),
|
||||
Socket: signer.Socket,
|
||||
PubkeyG1: SerializeG1(signer.PkG1),
|
||||
PubkeyG2: SerializeG2(signer.PkG2),
|
||||
},
|
||||
Signature: SerializeG1(args[1].(BN254G1Point)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewMsgRegisterNextEpoch(args []interface{}, account string) (*dasignerstypes.MsgRegisterNextEpoch, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.MsgRegisterNextEpoch{
|
||||
Account: account,
|
||||
Signature: SerializeG1(args[0].(BN254G1Point)),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func NewMsgUpdateSocket(args []interface{}, account string) (*dasignerstypes.MsgUpdateSocket, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf(precopmiles_common.ErrInvalidNumberOfArgs, 1, len(args))
|
||||
}
|
||||
|
||||
return &dasignerstypes.MsgUpdateSocket{
|
||||
Account: account,
|
||||
Socket: args[0].(string),
|
||||
}, nil
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
syntax = "proto3";
|
||||
package zgc.das.v1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/das/v1/types";
|
||||
|
||||
message Params {}
|
||||
|
||||
// GenesisState defines the das module's genesis state.
|
||||
message GenesisState {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
uint64 next_request_id = 2 [(gogoproto.customname) = "NextRequestID"];
|
||||
repeated DASRequest requests = 3 [(gogoproto.nullable) = false];
|
||||
repeated DASResponse responses = 4 [(gogoproto.nullable) = false];
|
||||
}
|
||||
|
||||
message DASRequest {
|
||||
uint64 id = 1 [(gogoproto.customname) = "ID"];
|
||||
bytes stream_id = 2 [(gogoproto.customname) = "StreamID"];
|
||||
bytes batch_header_hash = 3;
|
||||
uint32 num_blobs = 4;
|
||||
}
|
||||
|
||||
message DASResponse {
|
||||
uint64 id = 1 [(gogoproto.customname) = "ID"];
|
||||
bytes sampler = 2 [
|
||||
(cosmos_proto.scalar) = "cosmos.AddressBytes",
|
||||
(gogoproto.casttype) = "github.com/cosmos/cosmos-sdk/types.ValAddress"
|
||||
];
|
||||
repeated bool results = 3;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
syntax = "proto3";
|
||||
package zgc.das.v1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/das/v1/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Query defines the gRPC querier service for the das module
|
||||
service Query {
|
||||
rpc NextRequestID(QueryNextRequestIDRequest) returns (QueryNextRequestIDResponse) {
|
||||
option (google.api.http).get = "/0gchain/das/v1/next-request-id";
|
||||
}
|
||||
}
|
||||
|
||||
message QueryNextRequestIDRequest {}
|
||||
|
||||
message QueryNextRequestIDResponse {
|
||||
uint64 next_request_id = 1 [(gogoproto.customname) = "NextRequestID"];
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
syntax = "proto3";
|
||||
package zgc.das.v1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "zgc/das/v1/genesis.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/das/v1/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Msg defines the das Msg service
|
||||
service Msg {
|
||||
rpc RequestDAS(MsgRequestDAS) returns (MsgRequestDASResponse);
|
||||
rpc ReportDASResult(MsgReportDASResult) returns (MsgReportDASResultResponse);
|
||||
}
|
||||
|
||||
message MsgRequestDAS {
|
||||
string requester = 1 [(gogoproto.moretags) = "Requester"];
|
||||
string stream_id = 2 [(gogoproto.customname) = "StreamID"];
|
||||
string batch_header_hash = 3;
|
||||
uint32 num_blobs = 4;
|
||||
}
|
||||
|
||||
message MsgRequestDASResponse {
|
||||
uint64 request_id = 1 [(gogoproto.customname) = "RequestID"];
|
||||
}
|
||||
|
||||
message MsgReportDASResult {
|
||||
uint64 request_id = 1 [(gogoproto.customname) = "RequestID"];
|
||||
string sampler = 2;
|
||||
repeated bool results = 3;
|
||||
}
|
||||
|
||||
message MsgReportDASResultResponse {}
|
29
proto/zgc/dasigners/v1/dasigners.proto
Normal file
29
proto/zgc/dasigners/v1/dasigners.proto
Normal file
@ -0,0 +1,29 @@
|
||||
syntax = "proto3";
|
||||
package zgc.dasigners.v1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/duration.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
message Signer {
|
||||
// account defines the hex address of signer without 0x
|
||||
string account = 1;
|
||||
// socket defines the da node socket address
|
||||
string socket = 2;
|
||||
// pubkey_g1 defines the public key on bn254 G1
|
||||
bytes pubkey_g1 = 3;
|
||||
// pubkey_g1 defines the public key on bn254 G2
|
||||
bytes pubkey_g2 = 4;
|
||||
}
|
||||
|
||||
message Quorum {
|
||||
repeated string signers = 1;
|
||||
}
|
||||
|
||||
message Quorums {
|
||||
repeated Quorum quorums = 1;
|
||||
}
|
30
proto/zgc/dasigners/v1/genesis.proto
Normal file
30
proto/zgc/dasigners/v1/genesis.proto
Normal file
@ -0,0 +1,30 @@
|
||||
syntax = "proto3";
|
||||
package zgc.dasigners.v1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "zgc/dasigners/v1/dasigners.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types";
|
||||
|
||||
message Params {
|
||||
uint64 tokens_per_vote = 1;
|
||||
uint64 max_votes_per_signer = 2;
|
||||
uint64 max_quorums = 3;
|
||||
uint64 epoch_blocks = 4;
|
||||
uint64 encoded_slices = 5;
|
||||
}
|
||||
|
||||
// GenesisState defines the dasigners module's genesis state.
|
||||
message GenesisState {
|
||||
// params defines all the parameters of related to deposit.
|
||||
Params params = 1 [(gogoproto.nullable) = false];
|
||||
// params epoch_number the epoch number
|
||||
uint64 epoch_number = 2;
|
||||
// signers defines all signers information
|
||||
repeated Signer signers = 3;
|
||||
// quorums_by_epoch defines chosen quorums by epoch
|
||||
repeated Quorums quorums_by_epoch = 4;
|
||||
}
|
87
proto/zgc/dasigners/v1/query.proto
Normal file
87
proto/zgc/dasigners/v1/query.proto
Normal file
@ -0,0 +1,87 @@
|
||||
syntax = "proto3";
|
||||
package zgc.dasigners.v1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/api/annotations.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "google/protobuf/timestamp.proto";
|
||||
import "zgc/dasigners/v1/dasigners.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Query defines the gRPC querier service for the dasigners module
|
||||
service Query {
|
||||
rpc EpochNumber(QueryEpochNumberRequest) returns (QueryEpochNumberResponse) {
|
||||
option (google.api.http).get = "/0g/dasigners/v1/epoch-number";
|
||||
}
|
||||
rpc QuorumCount(QueryQuorumCountRequest) returns (QueryQuorumCountResponse) {
|
||||
option (google.api.http).get = "/0g/dasigners/v1/quorum-count";
|
||||
}
|
||||
rpc EpochQuorum(QueryEpochQuorumRequest) returns (QueryEpochQuorumResponse) {
|
||||
option (google.api.http).get = "/0g/dasigners/v1/epoch-quorum";
|
||||
}
|
||||
rpc EpochQuorumRow(QueryEpochQuorumRowRequest) returns (QueryEpochQuorumRowResponse) {
|
||||
option (google.api.http).get = "/0g/dasigners/v1/epoch-quorum-row";
|
||||
}
|
||||
rpc AggregatePubkeyG1(QueryAggregatePubkeyG1Request) returns (QueryAggregatePubkeyG1Response) {
|
||||
option (google.api.http).get = "/0g/dasigners/v1/aggregate-pubkey-g1";
|
||||
}
|
||||
rpc Signer(QuerySignerRequest) returns (QuerySignerResponse) {
|
||||
option (google.api.http).get = "/0g/dasigners/v1/signer";
|
||||
}
|
||||
}
|
||||
|
||||
message QuerySignerRequest {
|
||||
repeated string accounts = 1;
|
||||
}
|
||||
|
||||
message QuerySignerResponse {
|
||||
repeated Signer signer = 1;
|
||||
}
|
||||
|
||||
message QueryEpochNumberRequest {}
|
||||
|
||||
message QueryEpochNumberResponse {
|
||||
uint64 epoch_number = 1;
|
||||
}
|
||||
|
||||
message QueryQuorumCountRequest {
|
||||
uint64 epoch_number = 1;
|
||||
}
|
||||
|
||||
message QueryQuorumCountResponse {
|
||||
uint64 quorum_count = 1;
|
||||
}
|
||||
|
||||
message QueryEpochQuorumRequest {
|
||||
uint64 epoch_number = 1;
|
||||
uint64 quorum_id = 2;
|
||||
}
|
||||
|
||||
message QueryEpochQuorumResponse {
|
||||
Quorum quorum = 1;
|
||||
}
|
||||
|
||||
message QueryEpochQuorumRowRequest {
|
||||
uint64 epoch_number = 1;
|
||||
uint64 quorum_id = 2;
|
||||
uint32 row_index = 3;
|
||||
}
|
||||
|
||||
message QueryEpochQuorumRowResponse {
|
||||
string signer = 1;
|
||||
}
|
||||
|
||||
message QueryAggregatePubkeyG1Request {
|
||||
uint64 epoch_number = 1;
|
||||
uint64 quorum_id = 2;
|
||||
bytes quorum_bitmap = 3;
|
||||
}
|
||||
|
||||
message QueryAggregatePubkeyG1Response {
|
||||
bytes aggregate_pubkey_g1 = 1;
|
||||
uint64 total = 2;
|
||||
uint64 hit = 3;
|
||||
}
|
38
proto/zgc/dasigners/v1/tx.proto
Normal file
38
proto/zgc/dasigners/v1/tx.proto
Normal file
@ -0,0 +1,38 @@
|
||||
syntax = "proto3";
|
||||
package zgc.dasigners.v1;
|
||||
|
||||
import "cosmos_proto/cosmos.proto";
|
||||
import "gogoproto/gogo.proto";
|
||||
import "google/protobuf/any.proto";
|
||||
import "zgc/dasigners/v1/dasigners.proto";
|
||||
|
||||
option go_package = "github.com/0glabs/0g-chain/x/dasigners/v1/types";
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
|
||||
// Msg defines the dasigners Msg service
|
||||
service Msg {
|
||||
rpc RegisterSigner(MsgRegisterSigner) returns (MsgRegisterSignerResponse);
|
||||
rpc UpdateSocket(MsgUpdateSocket) returns (MsgUpdateSocketResponse);
|
||||
rpc RegisterNextEpoch(MsgRegisterNextEpoch) returns (MsgRegisterNextEpochResponse);
|
||||
}
|
||||
|
||||
message MsgRegisterSigner {
|
||||
Signer signer = 1;
|
||||
bytes signature = 2;
|
||||
}
|
||||
|
||||
message MsgRegisterSignerResponse {}
|
||||
|
||||
message MsgUpdateSocket {
|
||||
string account = 1;
|
||||
string socket = 2;
|
||||
}
|
||||
|
||||
message MsgUpdateSocketResponse {}
|
||||
|
||||
message MsgRegisterNextEpoch {
|
||||
string account = 1;
|
||||
bytes signature = 2;
|
||||
}
|
||||
|
||||
message MsgRegisterNextEpochResponse {}
|
@ -13,7 +13,7 @@ message ConversionPair {
|
||||
option (gogoproto.goproto_getters) = false;
|
||||
|
||||
// ERC20 address of the token on the 0gChain EVM
|
||||
bytes zgChain_erc20_address = 1 [
|
||||
bytes zgchain_erc20_address = 1 [
|
||||
(gogoproto.customname) = "ZgChainERC20Address",
|
||||
(gogoproto.casttype) = "HexBytes"
|
||||
];
|
||||
|
@ -44,7 +44,7 @@ message MsgConvertERC20ToCoin {
|
||||
// 0gChain bech32 address that will receive the converted sdk.Coin.
|
||||
string receiver = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
// EVM 0x hex address of the ERC20 contract.
|
||||
string zgChain_erc20_address = 3 [(gogoproto.customname) = "ZgChainERC20Address"];
|
||||
string zgchain_erc20_address = 3 [(gogoproto.customname) = "ZgChainERC20Address"];
|
||||
// ERC20 token amount to convert.
|
||||
string amount = 4 [
|
||||
(cosmos_proto.scalar) = "cosmos.Int",
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/tests/e2e/testutil"
|
||||
"github.com/0glabs/0g-chain/tests/util"
|
||||
evmutiltypes "github.com/0glabs/0g-chain/x/evmutil/types"
|
||||
@ -63,7 +64,7 @@ func (suite *IntegrationTestSuite) setupAccountWithCosmosCoinERC20Balance(
|
||||
tx := util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{&msg},
|
||||
GasLimit: 4e5,
|
||||
FeeAmount: sdk.NewCoins(a0gi(big.NewInt(400))),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(400)),
|
||||
Data: "converting sdk coin to erc20",
|
||||
}
|
||||
res := user.SignAndBroadcastZgChainTx(tx)
|
||||
@ -102,7 +103,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoinsToFromERC20() {
|
||||
tx := util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{&convertToErc20Msg},
|
||||
GasLimit: 2e6,
|
||||
FeeAmount: sdk.NewCoins(a0gi(big.NewInt(2000))),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(2000)),
|
||||
Data: "converting sdk coin to erc20",
|
||||
}
|
||||
res := user.SignAndBroadcastZgChainTx(tx)
|
||||
@ -144,7 +145,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoinsToFromERC20() {
|
||||
tx = util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{&convertFromErc20Msg},
|
||||
GasLimit: 2e5,
|
||||
FeeAmount: sdk.NewCoins(a0gi(big.NewInt(200))),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
|
||||
Data: "converting erc20 to cosmos coin",
|
||||
}
|
||||
res = user.SignAndBroadcastZgChainTx(tx)
|
||||
@ -183,7 +184,7 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
|
||||
user,
|
||||
suite.ZgChain,
|
||||
2e6,
|
||||
sdk.NewCoins(a0gi(big.NewInt(1e4))),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
|
||||
[]sdk.Msg{&convertToErc20Msg},
|
||||
"this is a memo",
|
||||
).GetTx()
|
||||
@ -237,7 +238,7 @@ func (suite *IntegrationTestSuite) TestEIP712ConvertCosmosCoinsToFromERC20() {
|
||||
user,
|
||||
suite.ZgChain,
|
||||
2e5,
|
||||
sdk.NewCoins(a0gi(big.NewInt(200))),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
|
||||
[]sdk.Msg{&convertFromErc20Msg},
|
||||
"",
|
||||
).GetTx()
|
||||
@ -331,7 +332,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoins_ERC20Magic() {
|
||||
"cosmo-coin-converter-complex-alice", initialAliceAmount,
|
||||
)
|
||||
|
||||
gasMoney := sdk.NewCoins(a0gi(big.NewInt(1e5)))
|
||||
gasMoney := sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e5))
|
||||
bob := suite.ZgChain.NewFundedAccount("cosmo-coin-converter-complex-bob", gasMoney)
|
||||
amount := big.NewInt(1e3) // test assumes this is half of alice's balance.
|
||||
|
||||
@ -412,7 +413,7 @@ func (suite *IntegrationTestSuite) TestConvertCosmosCoins_ERC20Magic() {
|
||||
convertTx := util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{&convertMsg},
|
||||
GasLimit: 2e5,
|
||||
FeeAmount: sdk.NewCoins(a0gi(big.NewInt(200))),
|
||||
FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(200)),
|
||||
Data: "bob converts his new erc20 to an sdk.Coin",
|
||||
}
|
||||
convertRes := bob.SignAndBroadcastZgChainTx(convertTx)
|
||||
|
@ -11,7 +11,7 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/tests/e2e/contracts/greeter"
|
||||
"github.com/0glabs/0g-chain/tests/util"
|
||||
)
|
||||
@ -20,7 +20,7 @@ func (suite *IntegrationTestSuite) TestEthCallToGreeterContract() {
|
||||
// this test manipulates state of the Greeter contract which means other tests shouldn't use it.
|
||||
|
||||
// setup funded account to interact with contract
|
||||
user := suite.ZgChain.NewFundedAccount("greeter-contract-user", sdk.NewCoins(a0gi(big.NewInt(1e6))))
|
||||
user := suite.ZgChain.NewFundedAccount("greeter-contract-user", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e6)))
|
||||
|
||||
greeterAddr := suite.ZgChain.ContractAddrs["greeter"]
|
||||
contract, err := greeter.NewGreeter(greeterAddr, suite.ZgChain.EvmClient)
|
||||
@ -63,12 +63,12 @@ func (suite *IntegrationTestSuite) TestEthCallToErc20() {
|
||||
|
||||
func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// create new funded account
|
||||
sender := suite.ZgChain.NewFundedAccount("eip712-msgSend", sdk.NewCoins(a0gi(big.NewInt(2e4))))
|
||||
sender := suite.ZgChain.NewFundedAccount("eip712-msgSend", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(2e4)))
|
||||
receiver := app.RandomAddress()
|
||||
|
||||
// setup message for sending some a0gi to random receiver
|
||||
// setup message for sending some gas denom to random receiver
|
||||
msgs := []sdk.Msg{
|
||||
banktypes.NewMsgSend(sender.SdkAddress, receiver, sdk.NewCoins(a0gi(big.NewInt(1e3)))),
|
||||
banktypes.NewMsgSend(sender.SdkAddress, receiver, sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e3))),
|
||||
}
|
||||
|
||||
// create tx
|
||||
@ -76,7 +76,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
sender,
|
||||
suite.ZgChain,
|
||||
1e6,
|
||||
sdk.NewCoins(a0gi(big.NewInt(1e4))),
|
||||
sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
|
||||
msgs,
|
||||
"this is a memo",
|
||||
).GetTx()
|
||||
@ -95,10 +95,10 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
_, err = util.WaitForSdkTxCommit(suite.ZgChain.Tx, res.TxResponse.TxHash, 6*time.Second)
|
||||
suite.NoError(err)
|
||||
|
||||
// check that the message was processed & the a0gi is transferred.
|
||||
// check that the message was processed & the gas denom is transferred.
|
||||
balRes, err := suite.ZgChain.Bank.Balance(context.Background(), &banktypes.QueryBalanceRequest{
|
||||
Address: receiver.String(),
|
||||
Denom: "ua0gi",
|
||||
Denom: chaincfg.GasDenom,
|
||||
})
|
||||
suite.NoError(err)
|
||||
suite.Equal(sdk.NewInt(1e3), balRes.Balance.Amount)
|
||||
@ -113,7 +113,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// sdkDenom := suite.DeployedErc20.CosmosDenom
|
||||
|
||||
// // create new funded account
|
||||
// depositor := suite.ZgChain.NewFundedAccount("eip712-lend-depositor", sdk.NewCoins(a0gi(big.NewInt(1e5)))
|
||||
// depositor := suite.ZgChain.NewFundedAccount("eip712-lend-depositor", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e5)))
|
||||
// // give them erc20 balance to deposit
|
||||
// fundRes := suite.FundZgChainErc20Balance(depositor.EvmAddress, amount.BigInt())
|
||||
// suite.NoError(fundRes.Err)
|
||||
@ -143,7 +143,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// depositor,
|
||||
// suite.ZgChain,
|
||||
// 1e6,
|
||||
// sdk.NewCoins(a0gi(big.NewInt(1e4)),
|
||||
// sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e4)),
|
||||
// msgs,
|
||||
// "doing the USDT Earn workflow! erc20 -> sdk.Coin -> USDX hard deposit",
|
||||
// ).GetTx()
|
||||
@ -189,7 +189,7 @@ func (suite *IntegrationTestSuite) TestEip712BasicMessageAuthorization() {
|
||||
// withdrawAndConvertBack := util.ZgChainMsgRequest{
|
||||
// Msgs: []sdk.Msg{&withdraw, &convertBack},
|
||||
// GasLimit: 1e6,
|
||||
// FeeAmount: sdk.NewCoins(a0gi(big.NewInt(1000)),
|
||||
// FeeAmount: sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1000)),
|
||||
// Data: "withdrawing from mint & converting back to erc20",
|
||||
// }
|
||||
// lastRes := depositor.SignAndBroadcastZgChainTx(withdrawAndConvertBack)
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
ethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/tests/util"
|
||||
)
|
||||
|
||||
@ -23,10 +24,10 @@ func (suite *IntegrationTestSuite) TestEthGasPriceReturnsMinFee() {
|
||||
minGasPrices, err := getMinFeeFromAppToml(util.ZgChainHomePath())
|
||||
suite.NoError(err)
|
||||
|
||||
// evm uses neuron, get neuron min fee
|
||||
evmMinGas := minGasPrices.AmountOf("neuron").TruncateInt().BigInt()
|
||||
// evm uses evm denom, get evm denom min fee
|
||||
evmMinGas := minGasPrices.AmountOf(chaincfg.EvmDenom).TruncateInt().BigInt()
|
||||
|
||||
// returns eth_gasPrice, units in a0gi
|
||||
// returns eth_gasPrice, units in gas denom
|
||||
gasPrice, err := suite.ZgChain.EvmClient.SuggestGasPrice(context.Background())
|
||||
suite.NoError(err)
|
||||
|
||||
@ -37,13 +38,13 @@ func (suite *IntegrationTestSuite) TestEvmRespectsMinFee() {
|
||||
suite.SkipIfKvtoolDisabled()
|
||||
|
||||
// setup sender & receiver
|
||||
sender := suite.ZgChain.NewFundedAccount("evm-min-fee-test-sender", sdk.NewCoins(a0gi(big.NewInt(1e3))))
|
||||
sender := suite.ZgChain.NewFundedAccount("evm-min-fee-test-sender", sdk.NewCoins(chaincfg.MakeCoinForGasDenom(1e3)))
|
||||
randoReceiver := util.SdkToEvmAddress(app.RandomAddress())
|
||||
|
||||
// get min gas price for evm (from app.toml)
|
||||
minFees, err := getMinFeeFromAppToml(util.ZgChainHomePath())
|
||||
suite.NoError(err)
|
||||
minGasPrice := minFees.AmountOf("neuron").TruncateInt()
|
||||
minGasPrice := minFees.AmountOf(chaincfg.EvmDenom).TruncateInt()
|
||||
|
||||
// attempt tx with less than min gas price (min fee - 1)
|
||||
tooLowGasPrice := minGasPrice.Sub(sdk.OneInt()).BigInt()
|
||||
|
@ -19,18 +19,15 @@ import (
|
||||
emtypes "github.com/evmos/ethermint/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/tests/e2e/testutil"
|
||||
"github.com/0glabs/0g-chain/tests/util"
|
||||
)
|
||||
|
||||
var (
|
||||
minEvmGasPrice = big.NewInt(1e10) // neuron
|
||||
minEvmGasPrice = big.NewInt(1e10) // evm denom
|
||||
)
|
||||
|
||||
func a0gi(amt *big.Int) sdk.Coin {
|
||||
return sdk.NewCoin("ua0gi", sdkmath.NewIntFromBigInt(amt))
|
||||
}
|
||||
|
||||
type IntegrationTestSuite struct {
|
||||
testutil.E2eTestSuite
|
||||
}
|
||||
@ -57,7 +54,7 @@ func (suite *IntegrationTestSuite) TestChainID() {
|
||||
|
||||
// example test that funds a new account & queries its balance
|
||||
func (suite *IntegrationTestSuite) TestFundedAccount() {
|
||||
funds := a0gi(big.NewInt(1e3))
|
||||
funds := chaincfg.MakeCoinForGasDenom(1e3)
|
||||
acc := suite.ZgChain.NewFundedAccount("example-acc", sdk.NewCoins(funds))
|
||||
|
||||
// check that the sdk & evm signers are for the same account
|
||||
@ -66,21 +63,21 @@ func (suite *IntegrationTestSuite) TestFundedAccount() {
|
||||
|
||||
// check balance via SDK query
|
||||
res, err := suite.ZgChain.Bank.Balance(context.Background(), banktypes.NewQueryBalanceRequest(
|
||||
acc.SdkAddress, "ua0gi",
|
||||
acc.SdkAddress, chaincfg.GasDenom,
|
||||
))
|
||||
suite.NoError(err)
|
||||
suite.Equal(funds, *res.Balance)
|
||||
|
||||
// check balance via EVM query
|
||||
neuronBal, err := suite.ZgChain.EvmClient.BalanceAt(context.Background(), acc.EvmAddress, nil)
|
||||
evmDenomBal, err := suite.ZgChain.EvmClient.BalanceAt(context.Background(), acc.EvmAddress, nil)
|
||||
suite.NoError(err)
|
||||
suite.Equal(funds.Amount.MulRaw(1e12).BigInt(), neuronBal)
|
||||
suite.Equal(funds.Amount.MulRaw(1e12).BigInt(), evmDenomBal)
|
||||
}
|
||||
|
||||
// example test that signs & broadcasts an EVM tx
|
||||
func (suite *IntegrationTestSuite) TestTransferOverEVM() {
|
||||
// fund an account that can perform the transfer
|
||||
initialFunds := a0gi(big.NewInt(1e6)) // 1 A0GI
|
||||
initialFunds := chaincfg.MakeCoinForGasDenom(1e6) // 1 (gas denom)
|
||||
acc := suite.ZgChain.NewFundedAccount("evm-test-transfer", sdk.NewCoins(initialFunds))
|
||||
|
||||
// get a rando account to send 0gchain to
|
||||
@ -92,10 +89,10 @@ func (suite *IntegrationTestSuite) TestTransferOverEVM() {
|
||||
suite.NoError(err)
|
||||
suite.Equal(uint64(0), nonce) // sanity check. the account should have no prior txs
|
||||
|
||||
// transfer a0gi over EVM
|
||||
a0giToTransfer := big.NewInt(1e17) // .1 A0GI; neuron has 18 decimals.
|
||||
// transfer gas denom over EVM
|
||||
GasDenomToTransfer := big.NewInt(1e17) // .1 (gas denom); evm denom has 18 decimals.
|
||||
req := util.EvmTxRequest{
|
||||
Tx: ethtypes.NewTransaction(nonce, to, a0giToTransfer, 1e5, minEvmGasPrice, nil),
|
||||
Tx: ethtypes.NewTransaction(nonce, to, GasDenomToTransfer, 1e5, minEvmGasPrice, nil),
|
||||
Data: "any ol' data to track this through the system",
|
||||
}
|
||||
res := acc.SignAndBroadcastEvmTx(req)
|
||||
@ -103,31 +100,31 @@ func (suite *IntegrationTestSuite) TestTransferOverEVM() {
|
||||
suite.Equal(ethtypes.ReceiptStatusSuccessful, res.Receipt.Status)
|
||||
|
||||
// evm txs refund unused gas. so to know the expected balance we need to know how much gas was used.
|
||||
a0giUsedForGas := sdkmath.NewIntFromBigInt(minEvmGasPrice).
|
||||
GasDenomUsedForGas := sdkmath.NewIntFromBigInt(minEvmGasPrice).
|
||||
Mul(sdkmath.NewIntFromUint64(res.Receipt.GasUsed)).
|
||||
QuoRaw(1e12) // convert neuron to a0gi
|
||||
QuoRaw(1e12) // convert evm denom to gas denom
|
||||
|
||||
// expect (9 - gas used) A0GI remaining in account.
|
||||
// expect (9 - gas used) (gas denom) remaining in account.
|
||||
balance := suite.ZgChain.QuerySdkForBalances(acc.SdkAddress)
|
||||
suite.Equal(sdkmath.NewInt(9e5).Sub(a0giUsedForGas), balance.AmountOf("ua0gi"))
|
||||
suite.Equal(sdkmath.NewInt(9e5).Sub(GasDenomUsedForGas), balance.AmountOf(chaincfg.GasDenom))
|
||||
}
|
||||
|
||||
// TestIbcTransfer transfers A0GI from the primary 0g-chain (suite.ZgChain) to the ibc chain (suite.Ibc).
|
||||
// TestIbcTransfer transfers (gas denom) from the primary 0g-chain (suite.ZgChain) to the ibc chain (suite.Ibc).
|
||||
// Note that because the IBC chain also runs 0g-chain's binary, this tests both the sending & receiving.
|
||||
func (suite *IntegrationTestSuite) TestIbcTransfer() {
|
||||
suite.SkipIfIbcDisabled()
|
||||
|
||||
// ARRANGE
|
||||
// setup 0g-chain account
|
||||
funds := a0gi(big.NewInt(1e5)) // .1 A0GI
|
||||
funds := chaincfg.MakeCoinForGasDenom(1e5) // .1 (gas denom)
|
||||
zgChainAcc := suite.ZgChain.NewFundedAccount("ibc-transfer-0g-side", sdk.NewCoins(funds))
|
||||
// setup ibc account
|
||||
ibcAcc := suite.Ibc.NewFundedAccount("ibc-transfer-ibc-side", sdk.NewCoins())
|
||||
|
||||
gasLimit := int64(2e5)
|
||||
fee := a0gi(big.NewInt(200))
|
||||
fee := chaincfg.MakeCoinForGasDenom(200)
|
||||
|
||||
fundsToSend := a0gi(big.NewInt(5e4)) // .005 A0GI
|
||||
fundsToSend := chaincfg.MakeCoinForGasDenom(5e4) // .005 (gas denom)
|
||||
transferMsg := ibctypes.NewMsgTransfer(
|
||||
testutil.IbcPort,
|
||||
testutil.IbcChannel,
|
||||
@ -157,7 +154,7 @@ func (suite *IntegrationTestSuite) TestIbcTransfer() {
|
||||
// the balance should be deducted from 0g-chain account
|
||||
suite.Eventually(func() bool {
|
||||
balance := suite.ZgChain.QuerySdkForBalances(zgChainAcc.SdkAddress)
|
||||
return balance.AmountOf("ua0gi").Equal(expectedSrcBalance.Amount)
|
||||
return balance.AmountOf(chaincfg.GasDenom).Equal(expectedSrcBalance.Amount)
|
||||
}, 10*time.Second, 1*time.Second)
|
||||
|
||||
// expect the balance to be transferred to the ibc chain!
|
||||
|
@ -3,7 +3,6 @@ package e2e_test
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -12,6 +11,7 @@ import (
|
||||
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
||||
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/tests/e2e/testutil"
|
||||
"github.com/0glabs/0g-chain/tests/util"
|
||||
)
|
||||
@ -101,13 +101,13 @@ func (suite *IntegrationTestSuite) TestModuleAccountGovTransfers() {
|
||||
name: "transfer from community to kavadist for incentive rewards",
|
||||
sender: communityAcc,
|
||||
receiver: zgChainDistAcc,
|
||||
amount: a0gi(big.NewInt(100)),
|
||||
amount: chaincfg.MakeCoinForGasDenom(100),
|
||||
},
|
||||
{
|
||||
name: "transfer from kavadist to community",
|
||||
sender: zgChainDistAcc,
|
||||
receiver: communityAcc,
|
||||
amount: a0gi(big.NewInt(50)),
|
||||
amount: chaincfg.MakeCoinForGasDenom(50),
|
||||
},
|
||||
}
|
||||
|
||||
@ -153,7 +153,7 @@ func (suite *IntegrationTestSuite) submitAndPassProposal(msgs []sdk.Msg) int64 {
|
||||
suite.NoError(err)
|
||||
|
||||
gasLimit := 1e6
|
||||
fee := sdk.NewCoin("neuron", sdk.NewInt(1e15))
|
||||
fee := chaincfg.MakeCoinForEvmDenom(1e15)
|
||||
|
||||
req := util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{proposalMsg},
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/ethereum/go-ethereum/ethclient"
|
||||
rpchttpclient "github.com/tendermint/tendermint/rpc/client/http"
|
||||
"google.golang.org/grpc"
|
||||
@ -81,7 +82,7 @@ var (
|
||||
EvmRpcUrl: "http://localhost:8545",
|
||||
|
||||
ChainId: "0gchainlocalnet_8888-1",
|
||||
StakingDenom: "ua0gi",
|
||||
StakingDenom: chaincfg.GasDenom,
|
||||
}
|
||||
kvtoolIbcChain = ChainDetails{
|
||||
RpcUrl: "http://localhost:26658",
|
||||
|
@ -262,7 +262,7 @@ func (a *SigningAccount) BankSend(to sdk.AccAddress, amount sdk.Coins) util.ZgCh
|
||||
util.ZgChainMsgRequest{
|
||||
Msgs: []sdk.Msg{banktypes.NewMsgSend(a.SdkAddress, to, amount)},
|
||||
GasLimit: 2e5, // 200,000 gas
|
||||
FeeAmount: sdk.NewCoins(sdk.NewCoin(a.gasDenom, sdkmath.NewInt(200))), // assume min gas price of .001a0gi
|
||||
FeeAmount: sdk.NewCoins(sdk.NewCoin(a.gasDenom, sdkmath.NewInt(200))), // assume min gas price of .001 gas denom
|
||||
Data: fmt.Sprintf("sending %s to %s", amount, to),
|
||||
},
|
||||
)
|
||||
|
@ -82,7 +82,7 @@ message Metadata {
|
||||
string description = 1;
|
||||
// denom_units represents the list of DenomUnit's for a given coin
|
||||
repeated DenomUnit denom_units = 2;
|
||||
// base represents the base denom (should be the DenomUnit with exponent = 0).
|
||||
// base represents the evm denom (should be the DenomUnit with exponent = 0).
|
||||
string base = 3;
|
||||
// display indicates the suggested denom that should be
|
||||
// displayed in clients.
|
||||
|
6
third_party/proto/cosmos/tx/v1beta1/tx.proto
vendored
6
third_party/proto/cosmos/tx/v1beta1/tx.proto
vendored
@ -234,18 +234,18 @@ message Tip {
|
||||
string tipper = 2 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
}
|
||||
|
||||
// AuxSignerData is the intermediary format that an auxiliary signer (e.g. a
|
||||
// AuxSignerData is the intermediary format that an gas signer (e.g. a
|
||||
// tipper) builds and sends to the fee payer (who will build and broadcast the
|
||||
// actual tx). AuxSignerData is not a valid tx in itself, and will be rejected
|
||||
// by the node if sent directly as-is.
|
||||
//
|
||||
// Since: cosmos-sdk 0.46
|
||||
message AuxSignerData {
|
||||
// address is the bech32-encoded address of the auxiliary signer. If using
|
||||
// address is the bech32-encoded address of the gas signer. If using
|
||||
// AuxSignerData across different chains, the bech32 prefix of the target
|
||||
// chain (where the final transaction is broadcasted) should be used.
|
||||
string address = 1 [(cosmos_proto.scalar) = "cosmos.AddressString"];
|
||||
// sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the auxiliary signer
|
||||
// sign_doc is the SIGN_MODE_DIRECT_AUX sign doc that the gas signer
|
||||
// signs. Note: we use the same sign doc even if we're signing with
|
||||
// LEGACY_AMINO_JSON.
|
||||
SignDocDirectAux sign_doc = 2;
|
||||
|
@ -6,13 +6,13 @@ option go_package = "github.com/cosmos/ibc-go/v6/modules/apps/transfer/types";
|
||||
|
||||
import "gogoproto/gogo.proto";
|
||||
|
||||
// DenomTrace contains the base denomination for ICS20 fungible tokens and the
|
||||
// DenomTrace contains the evm denomination for ICS20 fungible tokens and the
|
||||
// source tracing information path.
|
||||
message DenomTrace {
|
||||
// path defines the chain of port/channel identifiers used for tracing the
|
||||
// source of the fungible token.
|
||||
string path = 1;
|
||||
// base denomination of the relayed fungible token.
|
||||
// evm denomination of the relayed fungible token.
|
||||
string base_denom = 2;
|
||||
}
|
||||
|
||||
|
@ -106,7 +106,7 @@ func QueryCalcSwapIDCmd(queryRoute string) *cobra.Command {
|
||||
return &cobra.Command{
|
||||
Use: "calc-swapid [random-number-hash] [sender] [sender-other-chain]",
|
||||
Short: "calculate swap ID for the given random number hash, sender, and sender other chain",
|
||||
Example: "bep3 calc-swapid 0677bd8a303dd981810f34d8e5cc6507f13b391899b84d3c1be6c6045a17d747 kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny bnb1ud3q90r98l3mhd87kswv3h8cgrymzeljct8qn7",
|
||||
Example: "bep3 calc-swapid 0677bd8a303dd981810f34d8e5cc6507f13b391899b84d3c1be6c6045a17d747 0g1l0xsq2z7gqd7yly0g40y5836g0appumark77ny bnb1ud3q90r98l3mhd87kswv3h8cgrymzeljct8qn7",
|
||||
Args: cobra.MinimumNArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
@ -220,7 +220,7 @@ func QueryGetAtomicSwapsCmd(queryRoute string) *cobra.Command {
|
||||
Short: "query atomic swaps with optional filters",
|
||||
Long: strings.TrimSpace(`Query for all paginated atomic swaps that match optional filters:
|
||||
Example:
|
||||
$ kvcli q bep3 swaps --involve=kava1l0xsq2z7gqd7yly0g40y5836g0appumark77ny
|
||||
$ kvcli q bep3 swaps --involve=0g1l0xsq2z7gqd7yly0g40y5836g0appumark77ny
|
||||
$ kvcli q bep3 swaps --expiration=280
|
||||
$ kvcli q bep3 swaps --status=(Open|Completed|Expired)
|
||||
$ kvcli q bep3 swaps --direction=(Incoming|Outgoing)
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/x/bep3"
|
||||
"github.com/0glabs/0g-chain/x/bep3/keeper"
|
||||
"github.com/0glabs/0g-chain/x/bep3/types"
|
||||
@ -35,7 +36,7 @@ func (suite *MsgServerTestSuite) SetupTest() {
|
||||
|
||||
// Set up genesis state and initialize
|
||||
_, addrs := app.GeneratePrivKeyAddressPairs(3)
|
||||
coins := sdk.NewCoins(c("bnb", 10000000000), c("a0gi", 10000))
|
||||
coins := sdk.NewCoins(c("bnb", 10000000000), c(chaincfg.GasDenom, 10000))
|
||||
authGS := app.NewFundedGenStateWithSameCoins(tApp.AppCodec(), coins, addrs)
|
||||
tApp.InitializeFromGenesisStates(authGS, NewBep3GenStateMulti(cdc, addrs[0]))
|
||||
|
||||
|
@ -16,6 +16,7 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/x/bep3/keeper"
|
||||
"github.com/0glabs/0g-chain/x/bep3/types"
|
||||
)
|
||||
@ -41,7 +42,7 @@ func (suite *QuerierTestSuite) SetupTest() {
|
||||
|
||||
// Set up auth GenesisState
|
||||
_, addrs := app.GeneratePrivKeyAddressPairs(11)
|
||||
coins := sdk.NewCoins(c("bnb", 10000000000), c("a0gi", 10000))
|
||||
coins := sdk.NewCoins(c("bnb", 10000000000), c(chaincfg.GasDenom, 10000))
|
||||
authGS := app.NewFundedGenStateWithSameCoins(tApp.AppCodec(), coins, addrs)
|
||||
|
||||
tApp.InitializeFromGenesisStates(
|
||||
|
@ -1,57 +0,0 @@
|
||||
package v0_16
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/bep3/types"
|
||||
)
|
||||
|
||||
// resetSwapForZeroHeight updates swap expiry/close heights to work when the chain height is reset to zero.
|
||||
func resetSwapForZeroHeight(swap types.AtomicSwap) types.AtomicSwap {
|
||||
switch status := swap.Status; status {
|
||||
case types.SWAP_STATUS_COMPLETED:
|
||||
// Reset closed block to one so completed swaps are not held in long term storage too long.
|
||||
swap.ClosedBlock = 1
|
||||
case types.SWAP_STATUS_OPEN:
|
||||
switch dir := swap.Direction; dir {
|
||||
case types.SWAP_DIRECTION_INCOMING:
|
||||
// Open incoming swaps can be expired safely. They haven't been claimed yet, so the outgoing swap on bnb will just timeout.
|
||||
// The chain downtime cannot be accurately predicted, so it's easier to expire than to recalculate a correct expire height.
|
||||
swap.ExpireHeight = 1
|
||||
swap.Status = types.SWAP_STATUS_EXPIRED
|
||||
case types.SWAP_DIRECTION_OUTGOING:
|
||||
// Open outgoing swaps should be extended to allow enough time to claim after the chain launches.
|
||||
// They cannot be expired as there could be an open/claimed bnb swap.
|
||||
swap.ExpireHeight = 1 + 24686 // default timeout used when sending swaps from 0g
|
||||
case types.SWAP_DIRECTION_UNSPECIFIED:
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown bep3 swap direction '%s'", dir))
|
||||
}
|
||||
case types.SWAP_STATUS_EXPIRED:
|
||||
// Once a swap is marked expired the expire height is ignored. However reset to 1 to be sure.
|
||||
swap.ExpireHeight = 1
|
||||
case types.SWAP_STATUS_UNSPECIFIED:
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown bep3 swap status '%s'", status))
|
||||
}
|
||||
|
||||
return swap
|
||||
}
|
||||
|
||||
func resetSwapsForZeroHeight(oldSwaps types.AtomicSwaps) types.AtomicSwaps {
|
||||
newSwaps := make(types.AtomicSwaps, len(oldSwaps))
|
||||
for i, oldSwap := range oldSwaps {
|
||||
swap := resetSwapForZeroHeight(oldSwap)
|
||||
newSwaps[i] = swap
|
||||
}
|
||||
return newSwaps
|
||||
}
|
||||
|
||||
func Migrate(oldState types.GenesisState) *types.GenesisState {
|
||||
return &types.GenesisState{
|
||||
PreviousBlockTime: oldState.PreviousBlockTime,
|
||||
Params: oldState.Params,
|
||||
AtomicSwaps: resetSwapsForZeroHeight(oldState.AtomicSwaps),
|
||||
Supplies: oldState.Supplies,
|
||||
}
|
||||
}
|
@ -1,176 +0,0 @@
|
||||
package v0_16
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/suite"
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
|
||||
app "github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/x/bep3/types"
|
||||
)
|
||||
|
||||
type migrateTestSuite struct {
|
||||
suite.Suite
|
||||
|
||||
addresses []sdk.AccAddress
|
||||
v16genstate types.GenesisState
|
||||
cdc codec.Codec
|
||||
}
|
||||
|
||||
func (s *migrateTestSuite) SetupTest() {
|
||||
chaincfg.SetSDKConfig()
|
||||
|
||||
s.v16genstate = types.GenesisState{
|
||||
PreviousBlockTime: time.Date(2021, 4, 8, 15, 0, 0, 0, time.UTC),
|
||||
Params: types.Params{},
|
||||
Supplies: types.AssetSupplies{},
|
||||
AtomicSwaps: types.AtomicSwaps{},
|
||||
}
|
||||
|
||||
config := app.MakeEncodingConfig()
|
||||
s.cdc = config.Marshaler
|
||||
|
||||
_, accAddresses := app.GeneratePrivKeyAddressPairs(10)
|
||||
s.addresses = accAddresses
|
||||
}
|
||||
|
||||
func (s *migrateTestSuite) TestMigrate_JSON() {
|
||||
// Migrate v16 bep3 to v17
|
||||
file := filepath.Join("testdata", "v16-bep3.json")
|
||||
data, err := ioutil.ReadFile(file)
|
||||
s.Require().NoError(err)
|
||||
err = s.cdc.UnmarshalJSON(data, &s.v16genstate)
|
||||
s.Require().NoError(err)
|
||||
genstate := Migrate(s.v16genstate)
|
||||
|
||||
// Compare expect v16 bep3 json with migrated json
|
||||
actual := s.cdc.MustMarshalJSON(genstate)
|
||||
file = filepath.Join("testdata", "v17-bep3.json")
|
||||
expected, err := ioutil.ReadFile(file)
|
||||
s.Require().NoError(err)
|
||||
s.Require().JSONEq(string(expected), string(actual))
|
||||
}
|
||||
|
||||
func (s *migrateTestSuite) TestMigrate_Swaps() {
|
||||
type swap struct {
|
||||
ExpireHeight uint64
|
||||
CloseBlock int64
|
||||
Status types.SwapStatus
|
||||
Direction types.SwapDirection
|
||||
}
|
||||
testcases := []struct {
|
||||
name string
|
||||
oldSwap swap
|
||||
newSwap swap
|
||||
}{
|
||||
{
|
||||
name: "incoming open swap",
|
||||
oldSwap: swap{
|
||||
// expire and close not set in open swaps
|
||||
Status: types.SWAP_STATUS_OPEN,
|
||||
Direction: types.SWAP_DIRECTION_INCOMING,
|
||||
},
|
||||
newSwap: swap{
|
||||
ExpireHeight: 1,
|
||||
Status: types.SWAP_STATUS_EXPIRED,
|
||||
Direction: types.SWAP_DIRECTION_INCOMING,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "outgoing open swap",
|
||||
oldSwap: swap{
|
||||
// expire and close not set in open swaps
|
||||
Status: types.SWAP_STATUS_OPEN,
|
||||
Direction: types.SWAP_DIRECTION_OUTGOING,
|
||||
},
|
||||
newSwap: swap{
|
||||
ExpireHeight: 24687,
|
||||
Status: types.SWAP_STATUS_OPEN,
|
||||
Direction: types.SWAP_DIRECTION_OUTGOING,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "completed swap",
|
||||
oldSwap: swap{
|
||||
ExpireHeight: 1000,
|
||||
CloseBlock: 900,
|
||||
Status: types.SWAP_STATUS_COMPLETED,
|
||||
Direction: types.SWAP_DIRECTION_INCOMING,
|
||||
},
|
||||
newSwap: swap{
|
||||
ExpireHeight: 1000,
|
||||
CloseBlock: 1,
|
||||
Status: types.SWAP_STATUS_COMPLETED,
|
||||
Direction: types.SWAP_DIRECTION_INCOMING,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "expired swap",
|
||||
oldSwap: swap{
|
||||
ExpireHeight: 1000,
|
||||
CloseBlock: 900,
|
||||
Status: types.SWAP_STATUS_EXPIRED,
|
||||
Direction: types.SWAP_DIRECTION_INCOMING,
|
||||
},
|
||||
newSwap: swap{
|
||||
ExpireHeight: 1,
|
||||
CloseBlock: 900,
|
||||
Status: types.SWAP_STATUS_EXPIRED,
|
||||
Direction: types.SWAP_DIRECTION_INCOMING,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range testcases {
|
||||
s.Run(tc.name, func() {
|
||||
oldSwaps := types.AtomicSwaps{
|
||||
{
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(12))),
|
||||
RandomNumberHash: bytes.HexBytes{},
|
||||
ExpireHeight: tc.oldSwap.ExpireHeight,
|
||||
Timestamp: 1110,
|
||||
Sender: s.addresses[0],
|
||||
Recipient: s.addresses[1],
|
||||
RecipientOtherChain: s.addresses[0].String(),
|
||||
SenderOtherChain: s.addresses[1].String(),
|
||||
ClosedBlock: tc.oldSwap.CloseBlock,
|
||||
Status: tc.oldSwap.Status,
|
||||
CrossChain: true,
|
||||
Direction: tc.oldSwap.Direction,
|
||||
},
|
||||
}
|
||||
expectedSwaps := types.AtomicSwaps{
|
||||
{
|
||||
Amount: sdk.NewCoins(sdk.NewCoin("bnb", sdkmath.NewInt(12))),
|
||||
RandomNumberHash: bytes.HexBytes{},
|
||||
ExpireHeight: tc.newSwap.ExpireHeight,
|
||||
Timestamp: 1110,
|
||||
Sender: s.addresses[0],
|
||||
Recipient: s.addresses[1],
|
||||
RecipientOtherChain: s.addresses[0].String(),
|
||||
SenderOtherChain: s.addresses[1].String(),
|
||||
ClosedBlock: tc.newSwap.CloseBlock,
|
||||
Status: tc.newSwap.Status,
|
||||
CrossChain: true,
|
||||
Direction: tc.newSwap.Direction,
|
||||
},
|
||||
}
|
||||
s.v16genstate.AtomicSwaps = oldSwaps
|
||||
genState := Migrate(s.v16genstate)
|
||||
s.Require().Len(genState.AtomicSwaps, 1)
|
||||
s.Equal(expectedSwaps, genState.AtomicSwaps)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestMigrateTestSuite(t *testing.T) {
|
||||
suite.Run(t, new(migrateTestSuite))
|
||||
}
|
212
x/bep3/legacy/v0_17/testdata/v16-bep3.json
vendored
212
x/bep3/legacy/v0_17/testdata/v16-bep3.json
vendored
@ -1,212 +0,0 @@
|
||||
{
|
||||
"atomic_swaps": [
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "1999955998",
|
||||
"denom": "btcb"
|
||||
}
|
||||
],
|
||||
"closed_block": "838115",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_INCOMING",
|
||||
"expire_height": "838627",
|
||||
"random_number_hash": "6F1CF8F2E13A0C0F0A359F54E47E4E265D766B8E006D2F00BDF994ABDEF1E9E4",
|
||||
"recipient": "kava1fl2hs6y9vz986g5v52pdan9ga923n9mn5cxxkw",
|
||||
"recipient_other_chain": "bnb1xz3xqf4p2ygrw9lhp5g5df4ep4nd20vsywnmpr",
|
||||
"sender": "kava14qsmvzprqvhwmgql9fr0u3zv9n2qla8zhnm5pc",
|
||||
"sender_other_chain": "bnb19k9wuv2j7c7ck8tmc7kav0r0cnt3esmkrpf25x",
|
||||
"status": "SWAP_STATUS_COMPLETED",
|
||||
"timestamp": "1636034914"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "19000000000",
|
||||
"denom": "bnb"
|
||||
}
|
||||
],
|
||||
"closed_block": "1712118",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_OUTGOING",
|
||||
"expire_height": "1736797",
|
||||
"random_number_hash": "280EB832A37F2265CC82F3957CE603AAD57BAD7038B876A1F28953AFA29FA1C3",
|
||||
"recipient": "kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6",
|
||||
"recipient_other_chain": "bnb18nsgj50zvc4uq93w4j0ltz5gaxhwv7aq4qnq0p",
|
||||
"sender": "kava1zw6gg4ztvly7zf25pa33mclav3spvj3ympxxna",
|
||||
"sender_other_chain": "bnb1jh7uv2rm6339yue8k4mj9406k3509kr4wt5nxn",
|
||||
"status": "SWAP_STATUS_COMPLETED",
|
||||
"timestamp": "1641976566"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "999595462080",
|
||||
"denom": "busd"
|
||||
}
|
||||
],
|
||||
"closed_block": "787122",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_INCOMING",
|
||||
"expire_height": "811799",
|
||||
"random_number_hash": "BFB7CC82DA0E0C8556AC37843F5AB136B9A7A066054368F5948944282B414D83",
|
||||
"recipient": "kava1eufgf0w9d7hf5mgtek4zr2upkxag9stmzx6unl",
|
||||
"recipient_other_chain": "bnb10zq89008gmedc6rrwzdfukjk94swynd7dl97w8",
|
||||
"sender": "kava1hh4x3a4suu5zyaeauvmv7ypf7w9llwlfufjmuu",
|
||||
"sender_other_chain": "bnb1vl3wn4x8kqajg2j9wxa5y5amgzdxchutkxr6at",
|
||||
"status": "SWAP_STATUS_EXPIRED",
|
||||
"timestamp": "1635694492"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "999595462080",
|
||||
"denom": "busd"
|
||||
}
|
||||
],
|
||||
"closed_block": "787122",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_OUTGOING",
|
||||
"expire_height": "811799",
|
||||
"random_number_hash": "BFB7CC82DA0E0C8556AC37843F5AB136B9A7A066054368F5948944282B414D83",
|
||||
"recipient": "kava1hh4x3a4suu5zyaeauvmv7ypf7w9llwlfufjmuu",
|
||||
"recipient_other_chain": "bnb1vl3wn4x8kqajg2j9wxa5y5amgzdxchutkxr6at",
|
||||
"sender": "kava1eufgf0w9d7hf5mgtek4zr2upkxag9stmzx6unl",
|
||||
"sender_other_chain": "bnb10zq89008gmedc6rrwzdfukjk94swynd7dl97w8",
|
||||
"status": "SWAP_STATUS_EXPIRED",
|
||||
"timestamp": "1635694492"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "1000000",
|
||||
"denom": "btcb"
|
||||
}
|
||||
],
|
||||
"closed_block": "0",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_OUTGOING",
|
||||
"expire_height": "1730589",
|
||||
"random_number_hash": "A74EA1AB58D312FDF1E872D18583CACCF294E639DDA4F303939E9ADCEC081D93",
|
||||
"recipient": "kava14qsmvzprqvhwmgql9fr0u3zv9n2qla8zhnm5pc",
|
||||
"recipient_other_chain": "bnb1lhk5ndlgf5wz55t8k35cqj6h9l3m4l5ek2w7q6",
|
||||
"sender": "kava1d2u28azje7rhqyjtxc2ex8q0cxxpw7dfm7ltq5",
|
||||
"sender_other_chain": "bnb1xz3xqf4p2ygrw9lhp5g5df4ep4nd20vsywnmpr",
|
||||
"status": "SWAP_STATUS_OPEN",
|
||||
"timestamp": "1641934114"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "1000000",
|
||||
"denom": "btcb"
|
||||
}
|
||||
],
|
||||
"closed_block": "0",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_INCOMING",
|
||||
"expire_height": "1740000",
|
||||
"random_number_hash": "39E9ADCEC081D93A74EA1A83CACCF294E639DDA4F3039B58D312FDF1E872D185",
|
||||
"recipient": "kava1d2u28azje7rhqyjtxc2ex8q0cxxpw7dfm7ltq5",
|
||||
"recipient_other_chain": "bnb1xz3xqf4p2ygrw9lhp5g5df4ep4nd20vsywnmpr",
|
||||
"sender": "kava14qsmvzprqvhwmgql9fr0u3zv9n2qla8zhnm5pc",
|
||||
"sender_other_chain": "bnb1lhk5ndlgf5wz55t8k35cqj6h9l3m4l5ek2w7q6",
|
||||
"status": "SWAP_STATUS_OPEN",
|
||||
"timestamp": "1641934114"
|
||||
}
|
||||
],
|
||||
"params": {
|
||||
"asset_params": [
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "0",
|
||||
"denom": "btcb",
|
||||
"deputy_address": "kava1kla4wl0ccv7u85cemvs3y987hqk0afcv7vue84",
|
||||
"fixed_fee": "2",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "2000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "3",
|
||||
"supply_limit": {
|
||||
"limit": "100000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "144",
|
||||
"denom": "xrpb",
|
||||
"deputy_address": "kava14q5sawxdxtpap5x5sgzj7v4sp3ucncjlpuk3hs",
|
||||
"fixed_fee": "100000",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "250000000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "100001",
|
||||
"supply_limit": {
|
||||
"limit": "2000000000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "714",
|
||||
"denom": "bnb",
|
||||
"deputy_address": "kava1agcvt07tcw0tglu0hmwdecsnuxp2yd45f3avgm",
|
||||
"fixed_fee": "1000",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "500000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "1001",
|
||||
"supply_limit": {
|
||||
"limit": "100000000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "727",
|
||||
"denom": "busd",
|
||||
"deputy_address": "kava1j9je7f6s0v6k7dmgv6u5k5ru202f5ffsc7af04",
|
||||
"fixed_fee": "20000",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "100000000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "20001",
|
||||
"supply_limit": {
|
||||
"limit": "2000000000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"previous_block_time": "1970-01-01T00:00:00Z",
|
||||
"supplies": [
|
||||
{
|
||||
"current_supply": {
|
||||
"amount": "30467559434006",
|
||||
"denom": "bnb"
|
||||
},
|
||||
"incoming_supply": {
|
||||
"amount": "0",
|
||||
"denom": "bnb"
|
||||
},
|
||||
"outgoing_supply": {
|
||||
"amount": "0",
|
||||
"denom": "bnb"
|
||||
},
|
||||
"time_elapsed": "0s",
|
||||
"time_limited_current_supply": {
|
||||
"amount": "0",
|
||||
"denom": "bnb"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
212
x/bep3/legacy/v0_17/testdata/v17-bep3.json
vendored
212
x/bep3/legacy/v0_17/testdata/v17-bep3.json
vendored
@ -1,212 +0,0 @@
|
||||
{
|
||||
"atomic_swaps": [
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "1999955998",
|
||||
"denom": "btcb"
|
||||
}
|
||||
],
|
||||
"closed_block": "1",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_INCOMING",
|
||||
"expire_height": "838627",
|
||||
"random_number_hash": "6F1CF8F2E13A0C0F0A359F54E47E4E265D766B8E006D2F00BDF994ABDEF1E9E4",
|
||||
"recipient": "kava1fl2hs6y9vz986g5v52pdan9ga923n9mn5cxxkw",
|
||||
"recipient_other_chain": "bnb1xz3xqf4p2ygrw9lhp5g5df4ep4nd20vsywnmpr",
|
||||
"sender": "kava14qsmvzprqvhwmgql9fr0u3zv9n2qla8zhnm5pc",
|
||||
"sender_other_chain": "bnb19k9wuv2j7c7ck8tmc7kav0r0cnt3esmkrpf25x",
|
||||
"status": "SWAP_STATUS_COMPLETED",
|
||||
"timestamp": "1636034914"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "19000000000",
|
||||
"denom": "bnb"
|
||||
}
|
||||
],
|
||||
"closed_block": "1",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_OUTGOING",
|
||||
"expire_height": "1736797",
|
||||
"random_number_hash": "280EB832A37F2265CC82F3957CE603AAD57BAD7038B876A1F28953AFA29FA1C3",
|
||||
"recipient": "kava1r4v2zdhdalfj2ydazallqvrus9fkphmglhn6u6",
|
||||
"recipient_other_chain": "bnb18nsgj50zvc4uq93w4j0ltz5gaxhwv7aq4qnq0p",
|
||||
"sender": "kava1zw6gg4ztvly7zf25pa33mclav3spvj3ympxxna",
|
||||
"sender_other_chain": "bnb1jh7uv2rm6339yue8k4mj9406k3509kr4wt5nxn",
|
||||
"status": "SWAP_STATUS_COMPLETED",
|
||||
"timestamp": "1641976566"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "999595462080",
|
||||
"denom": "busd"
|
||||
}
|
||||
],
|
||||
"closed_block": "787122",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_INCOMING",
|
||||
"expire_height": "1",
|
||||
"random_number_hash": "BFB7CC82DA0E0C8556AC37843F5AB136B9A7A066054368F5948944282B414D83",
|
||||
"recipient": "kava1eufgf0w9d7hf5mgtek4zr2upkxag9stmzx6unl",
|
||||
"recipient_other_chain": "bnb10zq89008gmedc6rrwzdfukjk94swynd7dl97w8",
|
||||
"sender": "kava1hh4x3a4suu5zyaeauvmv7ypf7w9llwlfufjmuu",
|
||||
"sender_other_chain": "bnb1vl3wn4x8kqajg2j9wxa5y5amgzdxchutkxr6at",
|
||||
"status": "SWAP_STATUS_EXPIRED",
|
||||
"timestamp": "1635694492"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "999595462080",
|
||||
"denom": "busd"
|
||||
}
|
||||
],
|
||||
"closed_block": "787122",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_OUTGOING",
|
||||
"expire_height": "1",
|
||||
"random_number_hash": "BFB7CC82DA0E0C8556AC37843F5AB136B9A7A066054368F5948944282B414D83",
|
||||
"recipient": "kava1hh4x3a4suu5zyaeauvmv7ypf7w9llwlfufjmuu",
|
||||
"recipient_other_chain": "bnb1vl3wn4x8kqajg2j9wxa5y5amgzdxchutkxr6at",
|
||||
"sender": "kava1eufgf0w9d7hf5mgtek4zr2upkxag9stmzx6unl",
|
||||
"sender_other_chain": "bnb10zq89008gmedc6rrwzdfukjk94swynd7dl97w8",
|
||||
"status": "SWAP_STATUS_EXPIRED",
|
||||
"timestamp": "1635694492"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "1000000",
|
||||
"denom": "btcb"
|
||||
}
|
||||
],
|
||||
"closed_block": "0",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_OUTGOING",
|
||||
"expire_height": "24687",
|
||||
"random_number_hash": "A74EA1AB58D312FDF1E872D18583CACCF294E639DDA4F303939E9ADCEC081D93",
|
||||
"recipient": "kava14qsmvzprqvhwmgql9fr0u3zv9n2qla8zhnm5pc",
|
||||
"recipient_other_chain": "bnb1lhk5ndlgf5wz55t8k35cqj6h9l3m4l5ek2w7q6",
|
||||
"sender": "kava1d2u28azje7rhqyjtxc2ex8q0cxxpw7dfm7ltq5",
|
||||
"sender_other_chain": "bnb1xz3xqf4p2ygrw9lhp5g5df4ep4nd20vsywnmpr",
|
||||
"status": "SWAP_STATUS_OPEN",
|
||||
"timestamp": "1641934114"
|
||||
},
|
||||
{
|
||||
"amount": [
|
||||
{
|
||||
"amount": "1000000",
|
||||
"denom": "btcb"
|
||||
}
|
||||
],
|
||||
"closed_block": "0",
|
||||
"cross_chain": true,
|
||||
"direction": "SWAP_DIRECTION_INCOMING",
|
||||
"expire_height": "1",
|
||||
"random_number_hash": "39E9ADCEC081D93A74EA1A83CACCF294E639DDA4F3039B58D312FDF1E872D185",
|
||||
"recipient": "kava1d2u28azje7rhqyjtxc2ex8q0cxxpw7dfm7ltq5",
|
||||
"recipient_other_chain": "bnb1xz3xqf4p2ygrw9lhp5g5df4ep4nd20vsywnmpr",
|
||||
"sender": "kava14qsmvzprqvhwmgql9fr0u3zv9n2qla8zhnm5pc",
|
||||
"sender_other_chain": "bnb1lhk5ndlgf5wz55t8k35cqj6h9l3m4l5ek2w7q6",
|
||||
"status": "SWAP_STATUS_EXPIRED",
|
||||
"timestamp": "1641934114"
|
||||
}
|
||||
],
|
||||
"params": {
|
||||
"asset_params": [
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "0",
|
||||
"denom": "btcb",
|
||||
"deputy_address": "kava1kla4wl0ccv7u85cemvs3y987hqk0afcv7vue84",
|
||||
"fixed_fee": "2",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "2000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "3",
|
||||
"supply_limit": {
|
||||
"limit": "100000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "144",
|
||||
"denom": "xrpb",
|
||||
"deputy_address": "kava14q5sawxdxtpap5x5sgzj7v4sp3ucncjlpuk3hs",
|
||||
"fixed_fee": "100000",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "250000000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "100001",
|
||||
"supply_limit": {
|
||||
"limit": "2000000000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "714",
|
||||
"denom": "bnb",
|
||||
"deputy_address": "kava1agcvt07tcw0tglu0hmwdecsnuxp2yd45f3avgm",
|
||||
"fixed_fee": "1000",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "500000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "1001",
|
||||
"supply_limit": {
|
||||
"limit": "100000000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
},
|
||||
{
|
||||
"active": true,
|
||||
"coin_id": "727",
|
||||
"denom": "busd",
|
||||
"deputy_address": "kava1j9je7f6s0v6k7dmgv6u5k5ru202f5ffsc7af04",
|
||||
"fixed_fee": "20000",
|
||||
"max_block_lock": "86400",
|
||||
"max_swap_amount": "100000000000000",
|
||||
"min_block_lock": "24686",
|
||||
"min_swap_amount": "20001",
|
||||
"supply_limit": {
|
||||
"limit": "2000000000000000",
|
||||
"time_based_limit": "0",
|
||||
"time_limited": false,
|
||||
"time_period": "0s"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"previous_block_time": "1970-01-01T00:00:00Z",
|
||||
"supplies": [
|
||||
{
|
||||
"current_supply": {
|
||||
"amount": "30467559434006",
|
||||
"denom": "bnb"
|
||||
},
|
||||
"incoming_supply": {
|
||||
"amount": "0",
|
||||
"denom": "bnb"
|
||||
},
|
||||
"outgoing_supply": {
|
||||
"amount": "0",
|
||||
"denom": "bnb"
|
||||
},
|
||||
"time_elapsed": "0s",
|
||||
"time_limited_current_supply": {
|
||||
"amount": "0",
|
||||
"denom": "bnb"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -20,7 +20,7 @@ type GenesisTestSuite struct {
|
||||
}
|
||||
|
||||
func (suite *GenesisTestSuite) SetupTest() {
|
||||
coin := sdk.NewCoin("a0gi", sdk.OneInt())
|
||||
coin := chaincfg.MakeCoinForGasDenom(1)
|
||||
suite.swaps = atomicSwaps(10)
|
||||
|
||||
supply := types.NewAssetSupply(coin, coin, coin, coin, time.Duration(0))
|
||||
|
@ -5,12 +5,13 @@ import (
|
||||
"time"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestAssetSupplyValidate(t *testing.T) {
|
||||
coin := sdk.NewCoin("a0gi", sdk.OneInt())
|
||||
coin := chaincfg.MakeCoinForGasDenom(1)
|
||||
invalidCoin := sdk.Coin{Denom: "Invalid Denom", Amount: sdkmath.NewInt(-1)}
|
||||
testCases := []struct {
|
||||
msg string
|
||||
|
@ -6,12 +6,12 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/suite"
|
||||
|
||||
sdkmath "cosmossdk.io/math"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/x/committee/keeper"
|
||||
"github.com/0glabs/0g-chain/x/committee/types"
|
||||
)
|
||||
@ -61,7 +61,7 @@ func (suite *MsgServerTestSuite) SetupTest() {
|
||||
[]types.Proposal{},
|
||||
[]types.Vote{},
|
||||
)
|
||||
suite.communityPoolAmt = sdk.NewCoins(sdk.NewCoin("neuron", sdkmath.NewInt(1000000000000000)))
|
||||
suite.communityPoolAmt = sdk.NewCoins(chaincfg.MakeCoinForEvmDenom(1000000000000000))
|
||||
suite.app.InitializeFromGenesisStates(
|
||||
app.GenesisState{types.ModuleName: cdc.MustMarshalJSON(testGenesis)},
|
||||
// TODO: not used?
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
fmt "fmt"
|
||||
"time"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
@ -18,7 +19,7 @@ const (
|
||||
BaseCommitteeType = "0g/BaseCommittee"
|
||||
MemberCommitteeType = "0g/MemberCommittee" // Committee is composed of member addresses that vote to enact proposals within their permissions
|
||||
TokenCommitteeType = "0g/TokenCommittee" // Committee is composed of token holders with voting power determined by total token balance
|
||||
BondDenom = "neuron"
|
||||
BondDenom = chaincfg.BondDenom
|
||||
)
|
||||
|
||||
// Marshal needed for protobuf compatibility.
|
||||
|
@ -171,10 +171,10 @@ func NewVoteCmd() *cobra.Command {
|
||||
tokens = val.GetTokens()
|
||||
}
|
||||
}
|
||||
// the denom of token is neuron, need to convert to A0GI
|
||||
a0gi := tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000))
|
||||
// the denom of token is evm denom, need to convert to A0GI
|
||||
a0giTokenCnt := tokens.Quo(sdk.NewInt(1_000_000_000_000_000_000))
|
||||
// 1_000 0AGI token / vote
|
||||
numBallots := a0gi.Quo(sdk.NewInt(1_000)).Uint64()
|
||||
numBallots := a0giTokenCnt.Quo(sdk.NewInt(1_000)).Uint64()
|
||||
ballots := make([]*types.Ballot, numBallots)
|
||||
for i := range ballots {
|
||||
ballotID := uint64(i)
|
||||
|
@ -21,8 +21,8 @@ var (
|
||||
|
||||
const (
|
||||
// Amino names
|
||||
registerName = "evmos/council/MsgRegister"
|
||||
voteName = "evmos/council/MsgVote"
|
||||
registerName = "0g/council/MsgRegister"
|
||||
voteName = "0g/council/MsgVote"
|
||||
)
|
||||
|
||||
// NOTE: This is required for the GetSignBytes function
|
||||
|
@ -1,103 +0,0 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
"github.com/cosmos/cosmos-sdk/client/tx"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GetTxCmd returns the transaction commands for this module
|
||||
func GetTxCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
cmd.AddCommand(
|
||||
NewRequestDASCmd(),
|
||||
NewReportDASResultCmd(),
|
||||
)
|
||||
return cmd
|
||||
}
|
||||
|
||||
func NewRequestDASCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "request-das steram-id batch-header-hash num-blobs",
|
||||
Short: "Request data-availability-sampling",
|
||||
Args: cobra.ExactArgs(3),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
numBlobs, err := strconv.Atoi(args[2])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := types.NewMsgRequestDAS(clientCtx.GetFromAddress(), args[0], args[1], uint32(numBlobs))
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
|
||||
}
|
||||
|
||||
func NewReportDASResultCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "report-das-result request-id results",
|
||||
Short: "Report data-availability-sampling result",
|
||||
Args: cobra.MinimumNArgs(2),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
clientCtx, err := client.GetClientTxContext(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
requestID, err := strconv.ParseUint(args[0], 10, 64)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
n := len(args) - 1
|
||||
results := make([]bool, n)
|
||||
for i := 0; i < n; i++ {
|
||||
var err error
|
||||
results[i], err = strconv.ParseBool(args[i+1])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
// get account name by address
|
||||
accAddr := clientCtx.GetFromAddress()
|
||||
|
||||
samplerAddr, err := sdk.ValAddressFromHex(hex.EncodeToString(accAddr.Bytes()))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
msg := &types.MsgReportDASResult{
|
||||
RequestID: requestID,
|
||||
Sampler: samplerAddr.String(),
|
||||
Results: results,
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg)
|
||||
},
|
||||
}
|
||||
|
||||
flags.AddTxFlagsToCmd(cmd)
|
||||
return cmd
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
package das
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/das/v1/keeper"
|
||||
"github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the store state from a genesis state.
|
||||
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) {
|
||||
if err := gs.Validate(); err != nil {
|
||||
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
|
||||
}
|
||||
|
||||
keeper.SetNextRequestID(ctx, gs.NextRequestID)
|
||||
for _, req := range gs.Requests {
|
||||
keeper.SetDASRequest(ctx, req)
|
||||
}
|
||||
for _, resp := range gs.Responses {
|
||||
keeper.SetDASResponse(ctx, resp)
|
||||
}
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper.
|
||||
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
|
||||
nextRequestID, err := keeper.GetNextRequestID(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return types.NewGenesisState(
|
||||
nextRequestID,
|
||||
keeper.GetDASRequests(ctx),
|
||||
keeper.GetDASResponses(ctx),
|
||||
)
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = Keeper{}
|
||||
|
||||
func (k Keeper) NextRequestID(
|
||||
c context.Context,
|
||||
_ *types.QueryNextRequestIDRequest,
|
||||
) (*types.QueryNextRequestIDResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
nextRequestID, err := k.GetNextRequestID(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.QueryNextRequestIDResponse{NextRequestID: nextRequestID}, nil
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"strconv"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
)
|
||||
|
||||
type Keeper struct {
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
stakingKeeperRef types.StakingKeeperRef
|
||||
}
|
||||
|
||||
// NewKeeper creates a new das Keeper instance
|
||||
func NewKeeper(
|
||||
storeKey storetypes.StoreKey,
|
||||
cdc codec.BinaryCodec,
|
||||
stakingKeeper types.StakingKeeperRef,
|
||||
) Keeper {
|
||||
return Keeper{
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
stakingKeeperRef: stakingKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", "x/"+types.ModuleName)
|
||||
}
|
||||
|
||||
func (k Keeper) SetNextRequestID(ctx sdk.Context, id uint64) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(types.NextRequestIDKey, types.GetKeyFromID(id))
|
||||
}
|
||||
|
||||
func (k Keeper) GetNextRequestID(ctx sdk.Context) (uint64, error) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(types.NextRequestIDKey)
|
||||
if bz == nil {
|
||||
return 0, errorsmod.Wrap(types.ErrInvalidGenesis, "next request ID not set at genesis")
|
||||
}
|
||||
return types.Uint64FromBytes(bz), nil
|
||||
}
|
||||
|
||||
func (k Keeper) IncrementNextRequestID(ctx sdk.Context) error {
|
||||
id, err := k.GetNextRequestID(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
k.SetNextRequestID(ctx, id+1)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) GetDASRequest(ctx sdk.Context, requestID uint64) (types.DASRequest, bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RequestKeyPrefix)
|
||||
bz := store.Get(types.GetKeyFromID(requestID))
|
||||
if bz == nil {
|
||||
return types.DASRequest{}, false
|
||||
}
|
||||
var req types.DASRequest
|
||||
k.cdc.MustUnmarshal(bz, &req)
|
||||
return req, true
|
||||
}
|
||||
|
||||
func (k Keeper) SetDASRequest(ctx sdk.Context, req types.DASRequest) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.RequestKeyPrefix)
|
||||
bz := k.cdc.MustMarshal(&req)
|
||||
store.Set(types.GetKeyFromID(req.ID), bz)
|
||||
}
|
||||
|
||||
func (k Keeper) IterateDASRequest(ctx sdk.Context, cb func(req types.DASRequest) (stop bool)) {
|
||||
iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.RequestKeyPrefix)
|
||||
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var req types.DASRequest
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &req)
|
||||
if cb(req) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) GetDASRequests(ctx sdk.Context) []types.DASRequest {
|
||||
results := []types.DASRequest{}
|
||||
k.IterateDASRequest(ctx, func(req types.DASRequest) bool {
|
||||
results = append(results, req)
|
||||
return false
|
||||
})
|
||||
return results
|
||||
}
|
||||
|
||||
func (k Keeper) StoreNewDASRequest(
|
||||
ctx sdk.Context,
|
||||
streamIDHexStr string,
|
||||
batchHeaderHashHexStr string,
|
||||
numBlobs uint32) (uint64, error) {
|
||||
requestID, err := k.GetNextRequestID(ctx)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
streamID, err := hex.DecodeString(streamIDHexStr)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
batchHeaderHash, err := hex.DecodeString(batchHeaderHashHexStr)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
req := types.DASRequest{
|
||||
ID: requestID,
|
||||
StreamID: streamID,
|
||||
BatchHeaderHash: batchHeaderHash,
|
||||
NumBlobs: numBlobs,
|
||||
}
|
||||
k.SetDASRequest(ctx, req)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
types.EventTypeDASRequest,
|
||||
sdk.NewAttribute(types.AttributeKeyRequestID, strconv.FormatUint(requestID, 10)),
|
||||
sdk.NewAttribute(types.AttributeKeyStreamID, streamIDHexStr),
|
||||
sdk.NewAttribute(types.AttributeKeyBatchHeaderHash, batchHeaderHashHexStr),
|
||||
sdk.NewAttribute(types.AttributeKeyNumBlobs, strconv.FormatUint(uint64(numBlobs), 10)),
|
||||
),
|
||||
)
|
||||
|
||||
return requestID, nil
|
||||
}
|
||||
|
||||
func (k Keeper) GetDASResponse(
|
||||
ctx sdk.Context, requestID uint64, sampler sdk.ValAddress,
|
||||
) (types.DASResponse, bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ResponseKeyPrefix)
|
||||
bz := store.Get(types.GetResponseKey(requestID, sampler))
|
||||
if bz == nil {
|
||||
return types.DASResponse{}, false
|
||||
}
|
||||
var vote types.DASResponse
|
||||
k.cdc.MustUnmarshal(bz, &vote)
|
||||
return vote, true
|
||||
}
|
||||
|
||||
func (k Keeper) SetDASResponse(ctx sdk.Context, resp types.DASResponse) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.ResponseKeyPrefix)
|
||||
bz := k.cdc.MustMarshal(&resp)
|
||||
store.Set(types.GetResponseKey(resp.ID, resp.Sampler), bz)
|
||||
}
|
||||
|
||||
func (k Keeper) IterateDASResponse(ctx sdk.Context, cb func(resp types.DASResponse) (stop bool)) {
|
||||
iterator := sdk.KVStorePrefixIterator(ctx.KVStore(k.storeKey), types.ResponseKeyPrefix)
|
||||
|
||||
defer iterator.Close()
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var resp types.DASResponse
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &resp)
|
||||
if cb(resp) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) GetDASResponses(ctx sdk.Context) []types.DASResponse {
|
||||
results := []types.DASResponse{}
|
||||
k.IterateDASResponse(ctx, func(resp types.DASResponse) bool {
|
||||
results = append(results, resp)
|
||||
return false
|
||||
})
|
||||
return results
|
||||
}
|
||||
|
||||
func (k Keeper) StoreNewDASResponse(
|
||||
ctx sdk.Context, requestID uint64, sampler sdk.ValAddress, results []bool) error {
|
||||
if _, found := k.GetDASRequest(ctx, requestID); !found {
|
||||
return errorsmod.Wrapf(types.ErrUnknownRequest, "%d", requestID)
|
||||
}
|
||||
|
||||
k.SetDASResponse(ctx, types.DASResponse{
|
||||
ID: requestID,
|
||||
Sampler: sampler,
|
||||
Results: results,
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = &Keeper{}
|
||||
|
||||
// RequestDAS handles MsgRequestDAS messages
|
||||
func (k Keeper) RequestDAS(
|
||||
goCtx context.Context, msg *types.MsgRequestDAS,
|
||||
) (*types.MsgRequestDASResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
requestID, err := k.StoreNewDASRequest(ctx, msg.StreamID, msg.BatchHeaderHash, msg.NumBlobs)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
k.IncrementNextRequestID(ctx)
|
||||
return &types.MsgRequestDASResponse{
|
||||
RequestID: requestID,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// ReportDASResult handles MsgReportDASResult messages
|
||||
func (k Keeper) ReportDASResult(
|
||||
goCtx context.Context, msg *types.MsgReportDASResult,
|
||||
) (*types.MsgReportDASResultResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
|
||||
sampler, err := sdk.ValAddressFromBech32(msg.Sampler)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, found := k.stakingKeeperRef.GetValidator(ctx, sampler); !found {
|
||||
return nil, stakingtypes.ErrNoValidatorFound
|
||||
}
|
||||
|
||||
if err := k.StoreNewDASResponse(ctx, msg.RequestID, sampler, msg.Results); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.MsgReportDASResultResponse{}, nil
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package types
|
||||
|
||||
import errorsmod "cosmossdk.io/errors"
|
||||
|
||||
var (
|
||||
ErrUnknownRequest = errorsmod.Register(ModuleName, 0, "request not found")
|
||||
ErrInvalidGenesis = errorsmod.Register(ModuleName, 1, "invalid genesis")
|
||||
)
|
@ -1,11 +0,0 @@
|
||||
package types
|
||||
|
||||
// Module event types
|
||||
const (
|
||||
EventTypeDASRequest = "das_request"
|
||||
|
||||
AttributeKeyRequestID = "request_id"
|
||||
AttributeKeyStreamID = "stream_id"
|
||||
AttributeKeyBatchHeaderHash = "batch_header_hash"
|
||||
AttributeKeyNumBlobs = "num_blobs"
|
||||
)
|
@ -1,28 +0,0 @@
|
||||
package types
|
||||
|
||||
const (
|
||||
DefaultNextRequestID = 0
|
||||
)
|
||||
|
||||
// NewGenesisState returns a new genesis state object for the module.
|
||||
func NewGenesisState(nextRequestID uint64, requests []DASRequest, responses []DASResponse) *GenesisState {
|
||||
return &GenesisState{
|
||||
NextRequestID: nextRequestID,
|
||||
Requests: requests,
|
||||
Responses: responses,
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultGenesisState returns the default genesis state for the module.
|
||||
func DefaultGenesisState() *GenesisState {
|
||||
return NewGenesisState(
|
||||
DefaultNextRequestID,
|
||||
[]DASRequest{},
|
||||
[]DASResponse{},
|
||||
)
|
||||
}
|
||||
|
||||
// Validate performs basic validation of genesis data.
|
||||
func (gs GenesisState) Validate() error {
|
||||
return nil
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,44 +0,0 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
const (
|
||||
// ModuleName The name that will be used throughout the module
|
||||
ModuleName = "das"
|
||||
|
||||
// StoreKey Top level store key where all module items will be stored
|
||||
StoreKey = ModuleName
|
||||
)
|
||||
|
||||
// Key prefixes
|
||||
var (
|
||||
RequestKeyPrefix = []byte{0x00} // prefix for keys that store requests
|
||||
ResponseKeyPrefix = []byte{0x01} // prefix for keys that store responses
|
||||
|
||||
NextRequestIDKey = []byte{0x02}
|
||||
)
|
||||
|
||||
// GetKeyFromID returns the bytes to use as a key for a uint64 id
|
||||
func GetKeyFromID(id uint64) []byte {
|
||||
return Uint64ToBytes(id)
|
||||
}
|
||||
|
||||
func GetResponseKey(requestID uint64, sampler sdk.ValAddress) []byte {
|
||||
return append(GetKeyFromID(requestID), sampler.Bytes()...)
|
||||
}
|
||||
|
||||
// Uint64ToBytes converts a uint64 into fixed length bytes for use in store keys.
|
||||
func Uint64ToBytes(id uint64) []byte {
|
||||
bz := make([]byte, 8)
|
||||
binary.BigEndian.PutUint64(bz, uint64(id))
|
||||
return bz
|
||||
}
|
||||
|
||||
// Uint64FromBytes converts some fixed length bytes back into a uint64.
|
||||
func Uint64FromBytes(bz []byte) uint64 {
|
||||
return binary.BigEndian.Uint64(bz)
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
|
||||
var _, _ sdk.Msg = &MsgRequestDAS{}, &MsgReportDASResult{}
|
||||
|
||||
func NewMsgRequestDAS(fromAddr sdk.AccAddress, streamID, hash string, numBlobs uint32) *MsgRequestDAS {
|
||||
return &MsgRequestDAS{
|
||||
Requester: fromAddr.String(),
|
||||
StreamID: streamID,
|
||||
BatchHeaderHash: hash,
|
||||
NumBlobs: numBlobs,
|
||||
}
|
||||
}
|
||||
|
||||
func (msg MsgRequestDAS) GetSigners() []sdk.AccAddress {
|
||||
from, err := sdk.AccAddressFromBech32(msg.Requester)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{from}
|
||||
}
|
||||
|
||||
func (msg MsgRequestDAS) ValidateBasic() error {
|
||||
_, err := sdk.AccAddressFromBech32(msg.Requester)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid requester account address (%s)", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (msg *MsgReportDASResult) GetSigners() []sdk.AccAddress {
|
||||
samplerValAddr, err := sdk.ValAddressFromBech32(msg.Sampler)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
accAddr, err := sdk.AccAddressFromHexUnsafe(hex.EncodeToString(samplerValAddr.Bytes()))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return []sdk.AccAddress{accAddr}
|
||||
}
|
||||
|
||||
func (msg *MsgReportDASResult) ValidateBasic() error {
|
||||
_, err := sdk.ValAddressFromBech32(msg.Sampler)
|
||||
if err != nil {
|
||||
return errorsmod.Wrapf(sdkerrors.ErrInvalidAddress, "Invalid sampler validator address (%s)", err)
|
||||
}
|
||||
return nil
|
||||
}
|
@ -1,511 +0,0 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: zgc/das/v1/query.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
context "context"
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
grpc1 "github.com/gogo/protobuf/grpc"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
grpc "google.golang.org/grpc"
|
||||
codes "google.golang.org/grpc/codes"
|
||||
status "google.golang.org/grpc/status"
|
||||
_ "google.golang.org/protobuf/types/known/timestamppb"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type QueryNextRequestIDRequest struct {
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDRequest) Reset() { *m = QueryNextRequestIDRequest{} }
|
||||
func (m *QueryNextRequestIDRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryNextRequestIDRequest) ProtoMessage() {}
|
||||
func (*QueryNextRequestIDRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_d404c1962bca645f, []int{0}
|
||||
}
|
||||
func (m *QueryNextRequestIDRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *QueryNextRequestIDRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_QueryNextRequestIDRequest.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *QueryNextRequestIDRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryNextRequestIDRequest.Merge(m, src)
|
||||
}
|
||||
func (m *QueryNextRequestIDRequest) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *QueryNextRequestIDRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryNextRequestIDRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryNextRequestIDRequest proto.InternalMessageInfo
|
||||
|
||||
type QueryNextRequestIDResponse struct {
|
||||
NextRequestID uint64 `protobuf:"varint,1,opt,name=next_request_id,json=nextRequestId,proto3" json:"next_request_id,omitempty"`
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDResponse) Reset() { *m = QueryNextRequestIDResponse{} }
|
||||
func (m *QueryNextRequestIDResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*QueryNextRequestIDResponse) ProtoMessage() {}
|
||||
func (*QueryNextRequestIDResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_d404c1962bca645f, []int{1}
|
||||
}
|
||||
func (m *QueryNextRequestIDResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *QueryNextRequestIDResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_QueryNextRequestIDResponse.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *QueryNextRequestIDResponse) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_QueryNextRequestIDResponse.Merge(m, src)
|
||||
}
|
||||
func (m *QueryNextRequestIDResponse) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *QueryNextRequestIDResponse) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_QueryNextRequestIDResponse.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_QueryNextRequestIDResponse proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*QueryNextRequestIDRequest)(nil), "zgc.das.v1.QueryNextRequestIDRequest")
|
||||
proto.RegisterType((*QueryNextRequestIDResponse)(nil), "zgc.das.v1.QueryNextRequestIDResponse")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("zgc/das/v1/query.proto", fileDescriptor_d404c1962bca645f) }
|
||||
|
||||
var fileDescriptor_d404c1962bca645f = []byte{
|
||||
// 334 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x91, 0xbf, 0x4b, 0x03, 0x31,
|
||||
0x14, 0xc7, 0x2f, 0xa2, 0x0e, 0x81, 0x22, 0x1e, 0x22, 0xf6, 0x94, 0x54, 0x0b, 0xfe, 0x1a, 0x9a,
|
||||
0xb4, 0x3a, 0xb9, 0x16, 0x41, 0x5c, 0x04, 0x5d, 0x04, 0x97, 0x92, 0xbb, 0x8b, 0x69, 0xa0, 0x97,
|
||||
0x5c, 0x9b, 0x5c, 0x69, 0x3b, 0xba, 0xb8, 0x2a, 0xfe, 0x53, 0x1d, 0x0b, 0x2e, 0x4e, 0xa2, 0x57,
|
||||
0xff, 0x10, 0xe9, 0xe5, 0x0e, 0xad, 0x28, 0x6e, 0xef, 0xbd, 0xef, 0xf7, 0x7d, 0xf3, 0xe1, 0x05,
|
||||
0xae, 0x8f, 0x78, 0x40, 0x42, 0xaa, 0x49, 0xbf, 0x41, 0xba, 0x09, 0xeb, 0x0d, 0x71, 0xdc, 0x53,
|
||||
0x46, 0xb9, 0x70, 0xc4, 0x03, 0x1c, 0x52, 0x8d, 0xfb, 0x0d, 0xaf, 0x1c, 0x28, 0x1d, 0x29, 0xdd,
|
||||
0xca, 0x14, 0x62, 0x1b, 0x6b, 0xf3, 0xd6, 0xb8, 0xe2, 0xca, 0xce, 0x67, 0x55, 0x3e, 0xdd, 0xe2,
|
||||
0x4a, 0xf1, 0x0e, 0x23, 0x34, 0x16, 0x84, 0x4a, 0xa9, 0x0c, 0x35, 0x42, 0xc9, 0x62, 0xa7, 0x9c,
|
||||
0xab, 0x59, 0xe7, 0x27, 0xb7, 0x84, 0xca, 0xfc, 0x55, 0xaf, 0xf2, 0x53, 0x32, 0x22, 0x62, 0xda,
|
||||
0xd0, 0x28, 0xb6, 0x86, 0xea, 0x26, 0x2c, 0x5f, 0xce, 0x28, 0x2f, 0xd8, 0xc0, 0x5c, 0xb1, 0x6e,
|
||||
0xc2, 0xb4, 0x39, 0x3f, 0xcd, 0x8b, 0xea, 0x35, 0xf4, 0x7e, 0x13, 0x75, 0xac, 0xa4, 0x66, 0xee,
|
||||
0x09, 0x5c, 0x91, 0x6c, 0x60, 0x5a, 0x3d, 0xab, 0xb4, 0x44, 0xb8, 0x01, 0xb6, 0xc1, 0xc1, 0x62,
|
||||
0x73, 0x35, 0x7d, 0xad, 0x94, 0xe6, 0x77, 0x4a, 0xf2, 0x5b, 0x1b, 0x1e, 0x3d, 0x02, 0xb8, 0x94,
|
||||
0x25, 0xbb, 0xf7, 0x00, 0xce, 0x5b, 0xdd, 0x5d, 0xfc, 0x75, 0x29, 0xfc, 0x27, 0x9b, 0xb7, 0xf7,
|
||||
0x9f, 0xcd, 0x52, 0x56, 0xf7, 0xef, 0x9e, 0x3f, 0x9e, 0x16, 0x76, 0xdc, 0x0a, 0xa9, 0xf3, 0xa0,
|
||||
0x4d, 0x85, 0x2c, 0x3e, 0x67, 0x46, 0x54, 0xcb, 0xd9, 0x6b, 0x22, 0x6c, 0x9e, 0x8d, 0xdf, 0x91,
|
||||
0x33, 0x4e, 0x11, 0x98, 0xa4, 0x08, 0xbc, 0xa5, 0x08, 0x3c, 0x4c, 0x91, 0x33, 0x99, 0x22, 0xe7,
|
||||
0x65, 0x8a, 0x9c, 0x9b, 0x43, 0x2e, 0x4c, 0x3b, 0xf1, 0x71, 0xa0, 0x22, 0x52, 0xe7, 0x1d, 0xea,
|
||||
0x6b, 0x52, 0xe7, 0x35, 0x1b, 0x38, 0x28, 0x22, 0xcd, 0x30, 0x66, 0xda, 0x5f, 0xce, 0x2e, 0x7b,
|
||||
0xfc, 0x19, 0x00, 0x00, 0xff, 0xff, 0xd5, 0x9e, 0xd6, 0x49, 0x0a, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// QueryClient is the client API for Query service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
|
||||
type QueryClient interface {
|
||||
NextRequestID(ctx context.Context, in *QueryNextRequestIDRequest, opts ...grpc.CallOption) (*QueryNextRequestIDResponse, error)
|
||||
}
|
||||
|
||||
type queryClient struct {
|
||||
cc grpc1.ClientConn
|
||||
}
|
||||
|
||||
func NewQueryClient(cc grpc1.ClientConn) QueryClient {
|
||||
return &queryClient{cc}
|
||||
}
|
||||
|
||||
func (c *queryClient) NextRequestID(ctx context.Context, in *QueryNextRequestIDRequest, opts ...grpc.CallOption) (*QueryNextRequestIDResponse, error) {
|
||||
out := new(QueryNextRequestIDResponse)
|
||||
err := c.cc.Invoke(ctx, "/zgc.das.v1.Query/NextRequestID", in, out, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// QueryServer is the server API for Query service.
|
||||
type QueryServer interface {
|
||||
NextRequestID(context.Context, *QueryNextRequestIDRequest) (*QueryNextRequestIDResponse, error)
|
||||
}
|
||||
|
||||
// UnimplementedQueryServer can be embedded to have forward compatible implementations.
|
||||
type UnimplementedQueryServer struct {
|
||||
}
|
||||
|
||||
func (*UnimplementedQueryServer) NextRequestID(ctx context.Context, req *QueryNextRequestIDRequest) (*QueryNextRequestIDResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method NextRequestID not implemented")
|
||||
}
|
||||
|
||||
func RegisterQueryServer(s grpc1.Server, srv QueryServer) {
|
||||
s.RegisterService(&_Query_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Query_NextRequestID_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(QueryNextRequestIDRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(QueryServer).NextRequestID(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/zgc.das.v1.Query/NextRequestID",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(QueryServer).NextRequestID(ctx, req.(*QueryNextRequestIDRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Query_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "zgc.das.v1.Query",
|
||||
HandlerType: (*QueryServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "NextRequestID",
|
||||
Handler: _Query_NextRequestID_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "zgc/das/v1/query.proto",
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDRequest) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDRequest) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDResponse) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDResponse) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.NextRequestID != 0 {
|
||||
i = encodeVarintQuery(dAtA, i, uint64(m.NextRequestID))
|
||||
i--
|
||||
dAtA[i] = 0x8
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintQuery(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovQuery(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *QueryNextRequestIDRequest) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *QueryNextRequestIDResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.NextRequestID != 0 {
|
||||
n += 1 + sovQuery(uint64(m.NextRequestID))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovQuery(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozQuery(x uint64) (n int) {
|
||||
return sovQuery(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *QueryNextRequestIDRequest) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: QueryNextRequestIDRequest: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: QueryNextRequestIDRequest: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *QueryNextRequestIDResponse) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: QueryNextRequestIDResponse: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: QueryNextRequestIDResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 0 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field NextRequestID", wireType)
|
||||
}
|
||||
m.NextRequestID = 0
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
m.NextRequestID |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipQuery(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthQuery
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipQuery(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowQuery
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthQuery
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupQuery
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthQuery
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthQuery = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowQuery = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupQuery = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
@ -1,153 +0,0 @@
|
||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
||||
// source: zgc/das/v1/query.proto
|
||||
|
||||
/*
|
||||
Package types is a reverse proxy.
|
||||
|
||||
It translates gRPC into RESTful JSON APIs.
|
||||
*/
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/golang/protobuf/descriptor"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// Suppress "imported and not used" errors
|
||||
var _ codes.Code
|
||||
var _ io.Reader
|
||||
var _ status.Status
|
||||
var _ = runtime.String
|
||||
var _ = utilities.NewDoubleArray
|
||||
var _ = descriptor.ForMessage
|
||||
var _ = metadata.Join
|
||||
|
||||
func request_Query_NextRequestID_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryNextRequestIDRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := client.NextRequestID(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
func local_request_Query_NextRequestID_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
||||
var protoReq QueryNextRequestIDRequest
|
||||
var metadata runtime.ServerMetadata
|
||||
|
||||
msg, err := server.NextRequestID(ctx, &protoReq)
|
||||
return msg, metadata, err
|
||||
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerServer registers the http handlers for service Query to "mux".
|
||||
// UnaryRPC :call QueryServer directly.
|
||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterQueryHandlerFromEndpoint instead.
|
||||
func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, server QueryServer) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_NextRequestID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
var stream runtime.ServerTransportStream
|
||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := local_request_Query_NextRequestID_0(rctx, inboundMarshaler, server, req, pathParams)
|
||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_NextRequestID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerFromEndpoint is same as RegisterQueryHandler but
|
||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
||||
func RegisterQueryHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
||||
conn, err := grpc.Dial(endpoint, opts...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if err != nil {
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
return
|
||||
}
|
||||
go func() {
|
||||
<-ctx.Done()
|
||||
if cerr := conn.Close(); cerr != nil {
|
||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
||||
}
|
||||
}()
|
||||
}()
|
||||
|
||||
return RegisterQueryHandler(ctx, mux, conn)
|
||||
}
|
||||
|
||||
// RegisterQueryHandler registers the http handlers for service Query to "mux".
|
||||
// The handlers forward requests to the grpc endpoint over "conn".
|
||||
func RegisterQueryHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
||||
return RegisterQueryHandlerClient(ctx, mux, NewQueryClient(conn))
|
||||
}
|
||||
|
||||
// RegisterQueryHandlerClient registers the http handlers for service Query
|
||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "QueryClient".
|
||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "QueryClient"
|
||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
||||
// "QueryClient" to call the correct interceptors.
|
||||
func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, client QueryClient) error {
|
||||
|
||||
mux.Handle("GET", pattern_Query_NextRequestID_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
||||
ctx, cancel := context.WithCancel(req.Context())
|
||||
defer cancel()
|
||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
resp, md, err := request_Query_NextRequestID_0(rctx, inboundMarshaler, client, req, pathParams)
|
||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
||||
if err != nil {
|
||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
||||
return
|
||||
}
|
||||
|
||||
forward_Query_NextRequestID_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
||||
|
||||
})
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var (
|
||||
pattern_Query_NextRequestID_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"0gchain", "das", "v1", "next-request-id"}, "", runtime.AssumeColonVerbOpt(false)))
|
||||
)
|
||||
|
||||
var (
|
||||
forward_Query_NextRequestID_0 = runtime.ForwardResponseMessage
|
||||
)
|
File diff suppressed because it is too large
Load Diff
@ -6,7 +6,7 @@ import (
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/cosmos/cosmos-sdk/client/flags"
|
||||
)
|
||||
@ -15,23 +15,23 @@ import (
|
||||
func GetQueryCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: "Querying commands for the das module",
|
||||
Short: "Querying commands for the dasigners module",
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
GetNextRequestID(),
|
||||
GetEpochNumber(),
|
||||
)
|
||||
|
||||
return cmd
|
||||
}
|
||||
|
||||
func GetNextRequestID() *cobra.Command {
|
||||
func GetEpochNumber() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "next-request-id",
|
||||
Short: "Query the next request ID",
|
||||
Use: "epoch-number",
|
||||
Short: "Query current epoch number",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
clientCtx, err := client.GetClientQueryContext(cmd)
|
||||
@ -41,13 +41,13 @@ func GetNextRequestID() *cobra.Command {
|
||||
|
||||
queryClient := types.NewQueryClient(clientCtx)
|
||||
|
||||
params := &types.QueryNextRequestIDRequest{}
|
||||
res, err := queryClient.NextRequestID(context.Background(), params)
|
||||
params := &types.QueryEpochNumberRequest{}
|
||||
res, err := queryClient.EpochNumber(context.Background(), params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return clientCtx.PrintString(fmt.Sprintf("%v\n", res.NextRequestID))
|
||||
return clientCtx.PrintString(fmt.Sprintf("%v\n", res.EpochNumber))
|
||||
},
|
||||
}
|
||||
|
22
x/dasigners/v1/client/cli/tx.go
Normal file
22
x/dasigners/v1/client/cli/tx.go
Normal file
@ -0,0 +1,22 @@
|
||||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
"github.com/cosmos/cosmos-sdk/client"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// GetTxCmd returns the transaction commands for this module
|
||||
func GetTxCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: types.ModuleName,
|
||||
Short: fmt.Sprintf("%s transactions subcommands", types.ModuleName),
|
||||
DisableFlagParsing: true,
|
||||
SuggestionsMinimumDistance: 2,
|
||||
RunE: client.ValidateCmd,
|
||||
}
|
||||
cmd.AddCommand()
|
||||
return cmd
|
||||
}
|
50
x/dasigners/v1/genesis.go
Normal file
50
x/dasigners/v1/genesis.go
Normal file
@ -0,0 +1,50 @@
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/keeper"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
)
|
||||
|
||||
// InitGenesis initializes the store state from a genesis state.
|
||||
func InitGenesis(ctx sdk.Context, keeper keeper.Keeper, gs types.GenesisState) {
|
||||
if err := gs.Validate(); err != nil {
|
||||
panic(fmt.Sprintf("failed to validate %s genesis state: %s", types.ModuleName, err))
|
||||
}
|
||||
keeper.SetEpochNumber(ctx, gs.EpochNumber)
|
||||
for _, signer := range gs.Signers {
|
||||
if err := keeper.SetSigner(ctx, *signer); err != nil {
|
||||
panic(fmt.Sprintf("failed to write genesis state into store: %s", err))
|
||||
}
|
||||
}
|
||||
for epoch, quorums := range gs.QuorumsByEpoch {
|
||||
keeper.SetEpochQuorums(ctx, uint64(epoch), *quorums)
|
||||
}
|
||||
keeper.SetParams(ctx, gs.Params)
|
||||
}
|
||||
|
||||
// ExportGenesis returns a GenesisState for a given context and keeper.
|
||||
func ExportGenesis(ctx sdk.Context, keeper keeper.Keeper) *types.GenesisState {
|
||||
params := keeper.GetParams(ctx)
|
||||
epochNumber, err := keeper.GetEpochNumber(ctx)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
signers := make([]*types.Signer, 0)
|
||||
keeper.IterateSigners(ctx, func(_ int64, signer types.Signer) (stop bool) {
|
||||
signers = append(signers, &signer)
|
||||
return false
|
||||
})
|
||||
epochQuorums := make([]*types.Quorums, 0)
|
||||
for i := 0; i < int(epochNumber); i += 1 {
|
||||
quorums, found := keeper.GetEpochQuorums(ctx, uint64(i))
|
||||
if !found {
|
||||
panic("historical quorums not found")
|
||||
}
|
||||
epochQuorums = append(epochQuorums, &quorums)
|
||||
}
|
||||
return types.NewGenesisState(params, epochNumber, signers, epochQuorums)
|
||||
}
|
113
x/dasigners/v1/keeper/abci.go
Normal file
113
x/dasigners/v1/keeper/abci.go
Normal file
@ -0,0 +1,113 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"math/big"
|
||||
"sort"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
)
|
||||
|
||||
type Ballot struct {
|
||||
account string
|
||||
content []byte
|
||||
}
|
||||
|
||||
func (k Keeper) BeginBlock(ctx sdk.Context, _ abci.RequestBeginBlock) {
|
||||
epochNumber, err := k.GetEpochNumber(ctx)
|
||||
if err != nil {
|
||||
k.Logger(ctx).Error("[BeginBlock] cannot get epoch number")
|
||||
panic(err)
|
||||
}
|
||||
params := k.GetParams(ctx)
|
||||
expectedEpoch := uint64(ctx.BlockHeight()) / params.EpochBlocks
|
||||
if expectedEpoch == epochNumber {
|
||||
return
|
||||
}
|
||||
if expectedEpoch > epochNumber+1 || expectedEpoch < epochNumber {
|
||||
panic("block height is not continuous")
|
||||
}
|
||||
// new epoch
|
||||
registrations := []Ballot{}
|
||||
k.IterateRegistrations(ctx, expectedEpoch, func(account string, signature []byte) (stop bool) {
|
||||
registrations = append(registrations, Ballot{
|
||||
account: account,
|
||||
content: signature,
|
||||
})
|
||||
return false
|
||||
})
|
||||
ballots := []Ballot{}
|
||||
tokensPerVote := sdk.NewIntFromUint64(params.TokensPerVote)
|
||||
for _, registration := range registrations {
|
||||
// get validator
|
||||
accAddr, err := sdk.AccAddressFromHexUnsafe(registration.account)
|
||||
if err != nil {
|
||||
k.Logger(ctx).Error("[BeginBlock] invalid account")
|
||||
continue
|
||||
}
|
||||
bonded := k.GetDelegatorBonded(ctx, accAddr)
|
||||
num := bonded.Quo(BondedConversionRate).Quo(tokensPerVote).Abs().BigInt()
|
||||
if num.Cmp(big.NewInt(int64(params.MaxVotesPerSigner))) > 0 {
|
||||
num = big.NewInt(int64(params.MaxVotesPerSigner))
|
||||
}
|
||||
content := registration.content
|
||||
ballotNum := num.Int64()
|
||||
for j := 0; j < int(ballotNum); j += 1 {
|
||||
ballots = append(ballots, Ballot{
|
||||
account: registration.account,
|
||||
content: content,
|
||||
})
|
||||
content = crypto.Keccak256(content)
|
||||
}
|
||||
}
|
||||
sort.Slice(ballots, func(i, j int) bool {
|
||||
return bytes.Compare(ballots[i].content, ballots[j].content) < 0
|
||||
})
|
||||
|
||||
quorums := types.Quorums{
|
||||
Quorums: make([]*types.Quorum, 0),
|
||||
}
|
||||
if len(ballots) >= int(params.EncodedSlices) {
|
||||
for i := 0; i+int(params.EncodedSlices) <= len(ballots); i += int(params.EncodedSlices) {
|
||||
if int(params.MaxQuorums) < len(quorums.Quorums) {
|
||||
break
|
||||
}
|
||||
quorum := types.Quorum{
|
||||
Signers: make([]string, params.EncodedSlices),
|
||||
}
|
||||
for j := 0; j < int(params.EncodedSlices); j += 1 {
|
||||
quorum.Signers[j] = ballots[i+j].account
|
||||
}
|
||||
quorums.Quorums = append(quorums.Quorums, &quorum)
|
||||
}
|
||||
if len(ballots)%int(params.EncodedSlices) != 0 && int(params.MaxQuorums) > len(quorums.Quorums) {
|
||||
quorum := types.Quorum{
|
||||
Signers: make([]string, 0),
|
||||
}
|
||||
for j := len(ballots) - int(params.EncodedSlices); j < len(ballots); j += 1 {
|
||||
quorum.Signers = append(quorum.Signers, ballots[j].account)
|
||||
}
|
||||
quorums.Quorums = append(quorums.Quorums, &quorum)
|
||||
}
|
||||
} else if len(ballots) > 0 {
|
||||
quorum := types.Quorum{
|
||||
Signers: make([]string, params.EncodedSlices),
|
||||
}
|
||||
n := len(ballots)
|
||||
for i := 0; i < int(params.EncodedSlices); i += 1 {
|
||||
quorum.Signers[i] = ballots[i%n].account
|
||||
}
|
||||
quorums.Quorums = append(quorums.Quorums, &quorum)
|
||||
} else {
|
||||
quorums.Quorums = append(quorums.Quorums, &types.Quorum{
|
||||
Signers: make([]string, 0),
|
||||
})
|
||||
}
|
||||
|
||||
// save to store
|
||||
k.SetEpochQuorums(ctx, expectedEpoch, quorums)
|
||||
k.SetEpochNumber(ctx, expectedEpoch)
|
||||
}
|
127
x/dasigners/v1/keeper/grpc_query.go
Normal file
127
x/dasigners/v1/keeper/grpc_query.go
Normal file
@ -0,0 +1,127 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/0glabs/0g-chain/crypto/bn254util"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
"github.com/consensys/gnark-crypto/ecc/bn254"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
)
|
||||
|
||||
var _ types.QueryServer = Keeper{}
|
||||
|
||||
func (k Keeper) Signer(
|
||||
c context.Context,
|
||||
request *types.QuerySignerRequest,
|
||||
) (*types.QuerySignerResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
n := len(request.Accounts)
|
||||
response := types.QuerySignerResponse{Signer: make([]*types.Signer, n)}
|
||||
for i := 0; i < n; i += 1 {
|
||||
signer, found, err := k.GetSigner(ctx, request.Accounts[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
return nil, nil
|
||||
}
|
||||
response.Signer[i] = &signer
|
||||
}
|
||||
return &response, nil
|
||||
}
|
||||
|
||||
func (k Keeper) EpochNumber(
|
||||
c context.Context,
|
||||
_ *types.QueryEpochNumberRequest,
|
||||
) (*types.QueryEpochNumberResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
epochNumber, err := k.GetEpochNumber(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.QueryEpochNumberResponse{EpochNumber: epochNumber}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) QuorumCount(
|
||||
c context.Context,
|
||||
request *types.QueryQuorumCountRequest,
|
||||
) (*types.QueryQuorumCountResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
quorumCount, err := k.GetQuorumCount(ctx, request.EpochNumber)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.QueryQuorumCountResponse{QuorumCount: quorumCount}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) EpochQuorum(c context.Context, request *types.QueryEpochQuorumRequest) (*types.QueryEpochQuorumResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
quorums, found := k.GetEpochQuorums(ctx, request.EpochNumber)
|
||||
if !found {
|
||||
return nil, types.ErrQuorumNotFound
|
||||
}
|
||||
if len(quorums.Quorums) <= int(request.QuorumId) {
|
||||
return nil, types.ErrQuorumIdOutOfBound
|
||||
}
|
||||
return &types.QueryEpochQuorumResponse{Quorum: quorums.Quorums[request.QuorumId]}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) EpochQuorumRow(c context.Context, request *types.QueryEpochQuorumRowRequest) (*types.QueryEpochQuorumRowResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
quorums, found := k.GetEpochQuorums(ctx, request.EpochNumber)
|
||||
if !found {
|
||||
return nil, types.ErrQuorumNotFound
|
||||
}
|
||||
if len(quorums.Quorums) <= int(request.QuorumId) {
|
||||
return nil, types.ErrQuorumIdOutOfBound
|
||||
}
|
||||
signers := quorums.Quorums[request.QuorumId].Signers
|
||||
if len(signers) <= int(request.RowIndex) {
|
||||
return nil, types.ErrRowIndexOutOfBound
|
||||
}
|
||||
return &types.QueryEpochQuorumRowResponse{Signer: signers[request.RowIndex]}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) AggregatePubkeyG1(c context.Context, request *types.QueryAggregatePubkeyG1Request) (*types.QueryAggregatePubkeyG1Response, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
quorums, found := k.GetEpochQuorums(ctx, request.EpochNumber)
|
||||
if !found {
|
||||
return nil, types.ErrQuorumNotFound
|
||||
}
|
||||
if len(quorums.Quorums) <= int(request.QuorumId) {
|
||||
return nil, types.ErrQuorumIdOutOfBound
|
||||
}
|
||||
quorum := quorums.Quorums[request.QuorumId]
|
||||
if (len(quorum.Signers)+7)/8 != len(request.QuorumBitmap) {
|
||||
return nil, types.ErrQuorumBitmapLengthMismatch
|
||||
}
|
||||
aggPubkeyG1 := new(bn254.G1Affine)
|
||||
hit := 0
|
||||
added := make(map[string]struct{})
|
||||
for i, signer := range quorum.Signers {
|
||||
if _, ok := added[signer]; ok {
|
||||
hit += 1
|
||||
continue
|
||||
}
|
||||
b := request.QuorumBitmap[i/8] & (1 << (i % 8))
|
||||
if b == 0 {
|
||||
continue
|
||||
}
|
||||
hit += 1
|
||||
added[signer] = struct{}{}
|
||||
signer, found, err := k.GetSigner(ctx, signer)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
return nil, types.ErrSignerNotFound
|
||||
}
|
||||
aggPubkeyG1.Add(aggPubkeyG1, bn254util.DeserializeG1(signer.PubkeyG1))
|
||||
}
|
||||
return &types.QueryAggregatePubkeyG1Response{
|
||||
AggregatePubkeyG1: bn254util.SerializeG1(aggPubkeyG1),
|
||||
Total: uint64(len(quorum.Signers)),
|
||||
Hit: uint64(hit),
|
||||
}, nil
|
||||
}
|
239
x/dasigners/v1/keeper/keeper.go
Normal file
239
x/dasigners/v1/keeper/keeper.go
Normal file
@ -0,0 +1,239 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"math/big"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/cosmos/cosmos-sdk/codec"
|
||||
"github.com/cosmos/cosmos-sdk/store/prefix"
|
||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
"github.com/0glabs/0g-chain/chaincfg"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
)
|
||||
|
||||
var BondedConversionRate = math.NewIntFromBigInt(big.NewInt(0).Exp(big.NewInt(10), big.NewInt(chaincfg.GasDenomUnit), nil))
|
||||
|
||||
type Keeper struct {
|
||||
storeKey storetypes.StoreKey
|
||||
cdc codec.BinaryCodec
|
||||
stakingKeeper types.StakingKeeper
|
||||
}
|
||||
|
||||
// NewKeeper creates a new das Keeper instance
|
||||
func NewKeeper(
|
||||
storeKey storetypes.StoreKey,
|
||||
cdc codec.BinaryCodec,
|
||||
stakingKeeper types.StakingKeeper,
|
||||
) Keeper {
|
||||
return Keeper{
|
||||
storeKey: storeKey,
|
||||
cdc: cdc,
|
||||
stakingKeeper: stakingKeeper,
|
||||
}
|
||||
}
|
||||
|
||||
// Logger returns a module-specific logger.
|
||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
||||
return ctx.Logger().With("module", "x/"+types.ModuleName)
|
||||
}
|
||||
|
||||
func (k Keeper) GetParams(ctx sdk.Context) types.Params {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(types.ParamsKey)
|
||||
var params types.Params
|
||||
k.cdc.MustUnmarshal(bz, ¶ms)
|
||||
return params
|
||||
}
|
||||
|
||||
func (k Keeper) SetParams(ctx sdk.Context, params types.Params) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := k.cdc.MustMarshal(¶ms)
|
||||
store.Set(types.ParamsKey, bz)
|
||||
}
|
||||
|
||||
func (k Keeper) GetEpochNumber(ctx sdk.Context) (uint64, error) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
bz := store.Get(types.EpochNumberKey)
|
||||
if bz == nil {
|
||||
return 0, types.ErrEpochNumberNotSet
|
||||
}
|
||||
return sdk.BigEndianToUint64(bz), nil
|
||||
}
|
||||
|
||||
func (k Keeper) SetEpochNumber(ctx sdk.Context, epoch uint64) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
store.Set(types.EpochNumberKey, sdk.Uint64ToBigEndian(epoch))
|
||||
}
|
||||
|
||||
func (k Keeper) GetQuorumCount(ctx sdk.Context, epoch uint64) (uint64, error) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.QuorumCountKeyPrefix)
|
||||
bz := store.Get(types.GetQuorumCountKey(epoch))
|
||||
if bz == nil {
|
||||
return 0, types.ErrQuorumNotFound
|
||||
}
|
||||
return sdk.BigEndianToUint64(bz), nil
|
||||
}
|
||||
|
||||
func (k Keeper) SetQuorumCount(ctx sdk.Context, epoch uint64, quorums uint64) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.QuorumCountKeyPrefix)
|
||||
store.Set(types.GetQuorumCountKey(epoch), sdk.Uint64ToBigEndian(quorums))
|
||||
}
|
||||
|
||||
func (k Keeper) GetSigner(ctx sdk.Context, account string) (types.Signer, bool, error) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SignerKeyPrefix)
|
||||
key, err := types.GetSignerKeyFromAccount(account)
|
||||
if err != nil {
|
||||
return types.Signer{}, false, err
|
||||
}
|
||||
bz := store.Get(key)
|
||||
if bz == nil {
|
||||
return types.Signer{}, false, nil
|
||||
}
|
||||
var signer types.Signer
|
||||
k.cdc.MustUnmarshal(bz, &signer)
|
||||
return signer, true, nil
|
||||
}
|
||||
|
||||
func (k Keeper) SetSigner(ctx sdk.Context, signer types.Signer) error {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.SignerKeyPrefix)
|
||||
bz := k.cdc.MustMarshal(&signer)
|
||||
key, err := types.GetSignerKeyFromAccount(signer.Account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store.Set(key, bz)
|
||||
|
||||
ctx.EventManager().EmitEvent(
|
||||
sdk.NewEvent(
|
||||
types.EventTypeUpdateSigner,
|
||||
sdk.NewAttribute(types.AttributeKeySigner, signer.Account),
|
||||
sdk.NewAttribute(types.AttributeKeySocket, signer.Socket),
|
||||
sdk.NewAttribute(types.AttributeKeyPublicKeyG1, hex.EncodeToString(signer.PubkeyG1)),
|
||||
sdk.NewAttribute(types.AttributeKeyPublicKeyG2, hex.EncodeToString(signer.PubkeyG2)),
|
||||
),
|
||||
)
|
||||
return nil
|
||||
}
|
||||
|
||||
// iterate through the signers set and perform the provided function
|
||||
func (k Keeper) IterateSigners(ctx sdk.Context, fn func(index int64, signer types.Signer) (stop bool)) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
prefix := types.SignerKeyPrefix
|
||||
iterator := sdk.KVStorePrefixIterator(store, prefix)
|
||||
defer iterator.Close()
|
||||
|
||||
i := int64(0)
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
var signer types.Signer
|
||||
k.cdc.MustUnmarshal(iterator.Value(), &signer)
|
||||
stop := fn(i, signer)
|
||||
|
||||
if stop {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) GetEpochQuorums(ctx sdk.Context, epoch uint64) (types.Quorums, bool) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochQuorumsKeyPrefix)
|
||||
bz := store.Get(types.GetEpochQuorumsKeyFromEpoch(epoch))
|
||||
if bz == nil {
|
||||
return types.Quorums{}, false
|
||||
}
|
||||
var quorums types.Quorums
|
||||
k.cdc.MustUnmarshal(bz, &quorums)
|
||||
return quorums, true
|
||||
}
|
||||
|
||||
func (k Keeper) SetEpochQuorums(ctx sdk.Context, epoch uint64, quorums types.Quorums) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.EpochQuorumsKeyPrefix)
|
||||
bz := k.cdc.MustMarshal(&quorums)
|
||||
store.Set(types.GetEpochQuorumsKeyFromEpoch(epoch), bz)
|
||||
k.SetQuorumCount(ctx, epoch, uint64(len(quorums.Quorums)))
|
||||
}
|
||||
|
||||
func (k Keeper) GetRegistration(ctx sdk.Context, epoch uint64, account string) ([]byte, bool, error) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetEpochRegistrationKeyPrefix(epoch))
|
||||
key, err := types.GetRegistrationKey(account)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
signature := store.Get(key)
|
||||
if signature == nil {
|
||||
return nil, false, nil
|
||||
}
|
||||
return signature, true, nil
|
||||
}
|
||||
|
||||
// iterate through the registrations set and perform the provided function
|
||||
func (k Keeper) IterateRegistrations(ctx sdk.Context, epoch uint64, fn func(account string, signature []byte) (stop bool)) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
prefix := types.GetEpochRegistrationKeyPrefix(epoch)
|
||||
iterator := sdk.KVStorePrefixIterator(store, prefix)
|
||||
defer iterator.Close()
|
||||
|
||||
i := int64(0)
|
||||
|
||||
for ; iterator.Valid(); iterator.Next() {
|
||||
stop := fn(hex.EncodeToString((iterator.Key())[len(prefix):]), iterator.Value())
|
||||
|
||||
if stop {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
func (k Keeper) SetRegistration(ctx sdk.Context, epoch uint64, account string, signature []byte) error {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.GetEpochRegistrationKeyPrefix(epoch))
|
||||
key, err := types.GetRegistrationKey(account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store.Set(key, signature)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) GetDelegatorBonded(ctx sdk.Context, delegator sdk.AccAddress) math.Int {
|
||||
bonded := sdk.ZeroDec()
|
||||
|
||||
cnt := 0
|
||||
k.stakingKeeper.IterateDelegatorDelegations(ctx, delegator, func(delegation stakingtypes.Delegation) bool {
|
||||
validatorAddr, err := sdk.ValAddressFromBech32(delegation.ValidatorAddress)
|
||||
if err != nil {
|
||||
panic(err) // shouldn't happen
|
||||
}
|
||||
validator, found := k.stakingKeeper.GetValidator(ctx, validatorAddr)
|
||||
if found {
|
||||
shares := delegation.Shares
|
||||
tokens := validator.TokensFromSharesTruncated(shares)
|
||||
bonded = bonded.Add(tokens)
|
||||
}
|
||||
cnt += 1
|
||||
return cnt > 10
|
||||
})
|
||||
return bonded.RoundInt()
|
||||
}
|
||||
|
||||
func (k Keeper) CheckDelegations(ctx sdk.Context, account string) error {
|
||||
accAddr, err := sdk.AccAddressFromHexUnsafe(account)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
bonded := k.GetDelegatorBonded(ctx, accAddr)
|
||||
params := k.GetParams(ctx)
|
||||
tokensPerVote := sdk.NewIntFromUint64(params.TokensPerVote)
|
||||
if bonded.Quo(BondedConversionRate).Quo(tokensPerVote).Abs().BigInt().Cmp(big.NewInt(0)) <= 0 {
|
||||
return types.ErrInsufficientBonded
|
||||
}
|
||||
return nil
|
||||
}
|
91
x/dasigners/v1/keeper/msg_server.go
Normal file
91
x/dasigners/v1/keeper/msg_server.go
Normal file
@ -0,0 +1,91 @@
|
||||
package keeper
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/0glabs/0g-chain/crypto/bn254util"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
etherminttypes "github.com/evmos/ethermint/types"
|
||||
)
|
||||
|
||||
var _ types.MsgServer = &Keeper{}
|
||||
|
||||
func (k Keeper) RegisterSigner(goCtx context.Context, msg *types.MsgRegisterSigner) (*types.MsgRegisterSignerResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
// validate sender
|
||||
err := k.CheckDelegations(ctx, msg.Signer.Account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
_, found, err := k.GetSigner(ctx, msg.Signer.Account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if found {
|
||||
return nil, types.ErrSignerExists
|
||||
}
|
||||
// validate signature
|
||||
chainID, err := etherminttypes.ParseChainID(ctx.ChainID())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hash := types.PubkeyRegistrationHash(common.HexToAddress(msg.Signer.Account), chainID)
|
||||
if !msg.Signer.ValidateSignature(hash, bn254util.DeserializeG1(msg.Signature)) {
|
||||
return nil, types.ErrInvalidSignature
|
||||
}
|
||||
// save signer
|
||||
if err := k.SetSigner(ctx, *msg.Signer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgRegisterSignerResponse{}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) UpdateSocket(goCtx context.Context, msg *types.MsgUpdateSocket) (*types.MsgUpdateSocketResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
signer, found, err := k.GetSigner(ctx, msg.Account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
return nil, types.ErrSignerNotFound
|
||||
}
|
||||
signer.Socket = msg.Socket
|
||||
if err := k.SetSigner(ctx, signer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.MsgUpdateSocketResponse{}, nil
|
||||
}
|
||||
|
||||
func (k Keeper) RegisterNextEpoch(goCtx context.Context, msg *types.MsgRegisterNextEpoch) (*types.MsgRegisterNextEpochResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(goCtx)
|
||||
// get signer
|
||||
err := k.CheckDelegations(ctx, msg.Account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
signer, found, err := k.GetSigner(ctx, msg.Account)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if !found {
|
||||
return nil, types.ErrSignerNotFound
|
||||
}
|
||||
// validate signature
|
||||
epochNumber, err := k.GetEpochNumber(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
chainID, err := etherminttypes.ParseChainID(ctx.ChainID())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
hash := types.EpochRegistrationHash(common.HexToAddress(msg.Account), epochNumber+1, chainID)
|
||||
if !signer.ValidateSignature(hash, bn254util.DeserializeG1(msg.Signature)) {
|
||||
return nil, types.ErrInvalidSignature
|
||||
}
|
||||
// save registration
|
||||
k.SetRegistration(ctx, epochNumber+1, msg.Account, msg.Signature)
|
||||
return &types.MsgRegisterNextEpochResponse{}, nil
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package das
|
||||
package dasigners
|
||||
|
||||
import (
|
||||
"context"
|
||||
@ -11,14 +11,15 @@ import (
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/types/module"
|
||||
simtypes "github.com/cosmos/cosmos-sdk/types/simulation"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
||||
"github.com/spf13/cobra"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
|
||||
"github.com/0glabs/0g-chain/x/das/v1/client/cli"
|
||||
"github.com/0glabs/0g-chain/x/das/v1/keeper"
|
||||
"github.com/0glabs/0g-chain/x/das/v1/types"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/client/cli"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/keeper"
|
||||
"github.com/0glabs/0g-chain/x/dasigners/v1/types"
|
||||
)
|
||||
|
||||
// consensusVersion defines the current x/council module consensus version.
|
||||
@ -28,9 +29,6 @@ const consensusVersion = 1
|
||||
var (
|
||||
_ module.AppModule = AppModule{}
|
||||
_ module.AppModuleBasic = AppModuleBasic{}
|
||||
// _ module.AppModuleSimulation = AppModule{}
|
||||
_ module.BeginBlockAppModule = AppModule{}
|
||||
_ module.EndBlockAppModule = AppModule{}
|
||||
)
|
||||
|
||||
// app module Basics object
|
||||
@ -98,15 +96,18 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command {
|
||||
type AppModule struct {
|
||||
AppModuleBasic
|
||||
keeper keeper.Keeper
|
||||
sk stakingkeeper.Keeper
|
||||
}
|
||||
|
||||
// NewAppModule creates a new AppModule Object
|
||||
func NewAppModule(
|
||||
k keeper.Keeper,
|
||||
sk stakingkeeper.Keeper,
|
||||
) AppModule {
|
||||
return AppModule{
|
||||
AppModuleBasic: AppModuleBasic{},
|
||||
keeper: k,
|
||||
sk: sk,
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,13 +116,13 @@ func (AppModule) Name() string {
|
||||
return types.ModuleName
|
||||
}
|
||||
|
||||
// Route returns evmutil module's message route.
|
||||
// Route returns dasigners module's message route.
|
||||
func (am AppModule) Route() sdk.Route { return sdk.Route{} }
|
||||
|
||||
// QuerierRoute returns evmutil module's query routing key.
|
||||
func (AppModule) QuerierRoute() string { return "" }
|
||||
// QuerierRoute returns dasigners module's query routing key.
|
||||
func (AppModule) QuerierRoute() string { return types.QuerierRoute }
|
||||
|
||||
// LegacyQuerierHandler returns evmutil module's Querier.
|
||||
// LegacyQuerierHandler returns dasigners module's Querier.
|
||||
func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *codec.LegacyAmino) sdk.Querier {
|
||||
return nil
|
||||
}
|
||||
@ -137,7 +138,7 @@ func (am AppModule) RegisterServices(cfg module.Configurator) {
|
||||
}
|
||||
|
||||
func (am AppModule) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) {
|
||||
// am.keeper.BeginBlock(ctx, req)
|
||||
am.keeper.BeginBlock(ctx, req)
|
||||
}
|
||||
|
||||
func (am AppModule) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) []abci.ValidatorUpdate {
|
@ -18,9 +18,7 @@ var (
|
||||
)
|
||||
|
||||
const (
|
||||
// Amino names
|
||||
requestDASName = "evmos/das/MsgRequestDAS"
|
||||
reportDASResultName = "evmos/das/MsgReportDASResult"
|
||||
// Amino names
|
||||
)
|
||||
|
||||
// NOTE: This is required for the GetSignBytes function
|
||||
@ -33,8 +31,9 @@ func init() {
|
||||
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
registry.RegisterImplementations(
|
||||
(*sdk.Msg)(nil),
|
||||
&MsgRequestDAS{},
|
||||
&MsgReportDASResult{},
|
||||
&MsgRegisterSigner{},
|
||||
&MsgUpdateSocket{},
|
||||
&MsgRegisterNextEpoch{},
|
||||
)
|
||||
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
@ -42,6 +41,4 @@ func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
|
||||
|
||||
// RegisterLegacyAminoCodec required for EIP-712
|
||||
func RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) {
|
||||
cdc.RegisterConcrete(&MsgRequestDAS{}, requestDASName, nil)
|
||||
cdc.RegisterConcrete(&MsgReportDASResult{}, reportDASResultName, nil)
|
||||
}
|
802
x/dasigners/v1/types/dasigners.pb.go
Normal file
802
x/dasigners/v1/types/dasigners.pb.go
Normal file
@ -0,0 +1,802 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: zgc/dasigners/v1/dasigners.proto
|
||||
|
||||
package types
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
_ "github.com/cosmos/cosmos-proto"
|
||||
_ "github.com/cosmos/cosmos-sdk/codec/types"
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
_ "google.golang.org/protobuf/types/known/durationpb"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Signer struct {
|
||||
// account defines the hex address of signer without 0x
|
||||
Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"`
|
||||
// socket defines the da node socket address
|
||||
Socket string `protobuf:"bytes,2,opt,name=socket,proto3" json:"socket,omitempty"`
|
||||
// pubkey_g1 defines the public key on bn254 G1
|
||||
PubkeyG1 []byte `protobuf:"bytes,3,opt,name=pubkey_g1,json=pubkeyG1,proto3" json:"pubkey_g1,omitempty"`
|
||||
// pubkey_g1 defines the public key on bn254 G2
|
||||
PubkeyG2 []byte `protobuf:"bytes,4,opt,name=pubkey_g2,json=pubkeyG2,proto3" json:"pubkey_g2,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Signer) Reset() { *m = Signer{} }
|
||||
func (m *Signer) String() string { return proto.CompactTextString(m) }
|
||||
func (*Signer) ProtoMessage() {}
|
||||
func (*Signer) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_b7328dc8ffac059e, []int{0}
|
||||
}
|
||||
func (m *Signer) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Signer) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Signer.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Signer) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Signer.Merge(m, src)
|
||||
}
|
||||
func (m *Signer) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Signer) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Signer.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Signer proto.InternalMessageInfo
|
||||
|
||||
type Quorum struct {
|
||||
Signers []string `protobuf:"bytes,1,rep,name=signers,proto3" json:"signers,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Quorum) Reset() { *m = Quorum{} }
|
||||
func (m *Quorum) String() string { return proto.CompactTextString(m) }
|
||||
func (*Quorum) ProtoMessage() {}
|
||||
func (*Quorum) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_b7328dc8ffac059e, []int{1}
|
||||
}
|
||||
func (m *Quorum) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Quorum) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Quorum.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Quorum) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Quorum.Merge(m, src)
|
||||
}
|
||||
func (m *Quorum) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Quorum) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Quorum.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Quorum proto.InternalMessageInfo
|
||||
|
||||
type Quorums struct {
|
||||
Quorums []*Quorum `protobuf:"bytes,1,rep,name=quorums,proto3" json:"quorums,omitempty"`
|
||||
}
|
||||
|
||||
func (m *Quorums) Reset() { *m = Quorums{} }
|
||||
func (m *Quorums) String() string { return proto.CompactTextString(m) }
|
||||
func (*Quorums) ProtoMessage() {}
|
||||
func (*Quorums) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_b7328dc8ffac059e, []int{2}
|
||||
}
|
||||
func (m *Quorums) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *Quorums) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_Quorums.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *Quorums) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_Quorums.Merge(m, src)
|
||||
}
|
||||
func (m *Quorums) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *Quorums) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_Quorums.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_Quorums proto.InternalMessageInfo
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Signer)(nil), "zgc.dasigners.v1.Signer")
|
||||
proto.RegisterType((*Quorum)(nil), "zgc.dasigners.v1.Quorum")
|
||||
proto.RegisterType((*Quorums)(nil), "zgc.dasigners.v1.Quorums")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("zgc/dasigners/v1/dasigners.proto", fileDescriptor_b7328dc8ffac059e) }
|
||||
|
||||
var fileDescriptor_b7328dc8ffac059e = []byte{
|
||||
// 309 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x5c, 0x91, 0xb1, 0x6e, 0xea, 0x30,
|
||||
0x14, 0x86, 0xe3, 0xcb, 0x55, 0x28, 0x6e, 0x87, 0x2a, 0xaa, 0x2a, 0x43, 0x25, 0x2b, 0xca, 0xc4,
|
||||
0xd2, 0x98, 0xa4, 0x73, 0x97, 0x2e, 0x9d, 0x3a, 0x94, 0x6e, 0x5d, 0x90, 0x63, 0x52, 0x13, 0x01,
|
||||
0x39, 0x34, 0xb6, 0x51, 0xe1, 0x29, 0xfa, 0x58, 0x8c, 0x8c, 0x1d, 0x5b, 0x78, 0x91, 0x0a, 0x3b,
|
||||
0x88, 0xc2, 0x76, 0xbe, 0xff, 0xfb, 0xa5, 0x23, 0x1f, 0xe3, 0x70, 0x29, 0x05, 0x1b, 0x72, 0x55,
|
||||
0xc8, 0x32, 0xaf, 0x14, 0x9b, 0x27, 0x07, 0x88, 0x67, 0x15, 0x68, 0x08, 0x2e, 0x97, 0x52, 0xc4,
|
||||
0x87, 0x70, 0x9e, 0x74, 0xda, 0x02, 0xd4, 0x14, 0xd4, 0xc0, 0x7a, 0xe6, 0xc0, 0x95, 0x3b, 0x57,
|
||||
0x12, 0x24, 0xb8, 0x7c, 0x37, 0xd5, 0x69, 0x5b, 0x02, 0xc8, 0x49, 0xce, 0x2c, 0x65, 0xe6, 0x8d,
|
||||
0xf1, 0x72, 0x51, 0x2b, 0x7a, 0xaa, 0x86, 0xa6, 0xe2, 0xba, 0x80, 0xd2, 0xf9, 0x48, 0x63, 0xff,
|
||||
0xc5, 0x6e, 0x0e, 0x08, 0x6e, 0x72, 0x21, 0xc0, 0x94, 0x9a, 0xa0, 0x10, 0x75, 0x5b, 0xfd, 0x3d,
|
||||
0x06, 0xd7, 0xd8, 0x57, 0x20, 0xc6, 0xb9, 0x26, 0xff, 0xac, 0xa8, 0x29, 0xb8, 0xc1, 0xad, 0x99,
|
||||
0xc9, 0xc6, 0xf9, 0x62, 0x20, 0x13, 0xd2, 0x08, 0x51, 0xf7, 0xa2, 0x7f, 0xe6, 0x82, 0xc7, 0xe4,
|
||||
0xaf, 0x4c, 0xc9, 0xff, 0x23, 0x99, 0x46, 0x11, 0xf6, 0x9f, 0x0d, 0x54, 0x66, 0xba, 0xdb, 0x5a,
|
||||
0xbf, 0x9c, 0xa0, 0xb0, 0xb1, 0xdb, 0x5a, 0x63, 0x74, 0x8f, 0x9b, 0xae, 0xa3, 0x82, 0x14, 0x37,
|
||||
0xdf, 0xdd, 0x68, 0x4b, 0xe7, 0x29, 0x89, 0x4f, 0x8f, 0x16, 0xbb, 0x6e, 0x7f, 0x5f, 0x7c, 0x78,
|
||||
0x5a, 0xfd, 0x50, 0x6f, 0xb5, 0xa1, 0x68, 0xbd, 0xa1, 0xe8, 0x7b, 0x43, 0xd1, 0xe7, 0x96, 0x7a,
|
||||
0xeb, 0x2d, 0xf5, 0xbe, 0xb6, 0xd4, 0x7b, 0x65, 0xb2, 0xd0, 0x23, 0x93, 0xc5, 0x02, 0xa6, 0xac,
|
||||
0x27, 0x27, 0x3c, 0x53, 0xac, 0x27, 0x6f, 0xc5, 0x88, 0x17, 0x25, 0xfb, 0x38, 0xfe, 0x2f, 0xbd,
|
||||
0x98, 0xe5, 0x2a, 0xf3, 0xed, 0xb9, 0xee, 0x7e, 0x03, 0x00, 0x00, 0xff, 0xff, 0xc2, 0x80, 0xdc,
|
||||
0x60, 0xd0, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Signer) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Signer) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Signer) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.PubkeyG2) > 0 {
|
||||
i -= len(m.PubkeyG2)
|
||||
copy(dAtA[i:], m.PubkeyG2)
|
||||
i = encodeVarintDasigners(dAtA, i, uint64(len(m.PubkeyG2)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(m.PubkeyG1) > 0 {
|
||||
i -= len(m.PubkeyG1)
|
||||
copy(dAtA[i:], m.PubkeyG1)
|
||||
i = encodeVarintDasigners(dAtA, i, uint64(len(m.PubkeyG1)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(m.Socket) > 0 {
|
||||
i -= len(m.Socket)
|
||||
copy(dAtA[i:], m.Socket)
|
||||
i = encodeVarintDasigners(dAtA, i, uint64(len(m.Socket)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.Account) > 0 {
|
||||
i -= len(m.Account)
|
||||
copy(dAtA[i:], m.Account)
|
||||
i = encodeVarintDasigners(dAtA, i, uint64(len(m.Account)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Quorum) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Quorum) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Quorum) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Signers) > 0 {
|
||||
for iNdEx := len(m.Signers) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.Signers[iNdEx])
|
||||
copy(dAtA[i:], m.Signers[iNdEx])
|
||||
i = encodeVarintDasigners(dAtA, i, uint64(len(m.Signers[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *Quorums) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *Quorums) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *Quorums) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Quorums) > 0 {
|
||||
for iNdEx := len(m.Quorums) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Quorums[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintDasigners(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintDasigners(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovDasigners(v)
|
||||
base := offset
|
||||
for v >= 1<<7 {
|
||||
dAtA[offset] = uint8(v&0x7f | 0x80)
|
||||
v >>= 7
|
||||
offset++
|
||||
}
|
||||
dAtA[offset] = uint8(v)
|
||||
return base
|
||||
}
|
||||
func (m *Signer) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Account)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovDasigners(uint64(l))
|
||||
}
|
||||
l = len(m.Socket)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovDasigners(uint64(l))
|
||||
}
|
||||
l = len(m.PubkeyG1)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovDasigners(uint64(l))
|
||||
}
|
||||
l = len(m.PubkeyG2)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovDasigners(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Quorum) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Signers) > 0 {
|
||||
for _, s := range m.Signers {
|
||||
l = len(s)
|
||||
n += 1 + l + sovDasigners(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *Quorums) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Quorums) > 0 {
|
||||
for _, e := range m.Quorums {
|
||||
l = e.Size()
|
||||
n += 1 + l + sovDasigners(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovDasigners(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
func sozDasigners(x uint64) (n int) {
|
||||
return sovDasigners(uint64((x << 1) ^ uint64((int64(x) >> 63))))
|
||||
}
|
||||
func (m *Signer) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Signer: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Signer: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Account", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Account = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Socket", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Socket = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field PubkeyG1", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.PubkeyG1 = append(m.PubkeyG1[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.PubkeyG1 == nil {
|
||||
m.PubkeyG1 = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field PubkeyG2", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.PubkeyG2 = append(m.PubkeyG2[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.PubkeyG2 == nil {
|
||||
m.PubkeyG2 = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipDasigners(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Quorum) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Quorum: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Quorum: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Signers", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Signers = append(m.Signers, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipDasigners(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *Quorums) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Quorums: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Quorums: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Quorums", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Quorums = append(m.Quorums, &Quorum{})
|
||||
if err := m.Quorums[len(m.Quorums)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipDasigners(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthDasigners
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipDasigners(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
depth := 0
|
||||
for iNdEx < l {
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= (uint64(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
wireType := int(wire & 0x7)
|
||||
switch wireType {
|
||||
case 0:
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx++
|
||||
if dAtA[iNdEx-1] < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
case 1:
|
||||
iNdEx += 8
|
||||
case 2:
|
||||
var length int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return 0, ErrIntOverflowDasigners
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
length |= (int(b) & 0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if length < 0 {
|
||||
return 0, ErrInvalidLengthDasigners
|
||||
}
|
||||
iNdEx += length
|
||||
case 3:
|
||||
depth++
|
||||
case 4:
|
||||
if depth == 0 {
|
||||
return 0, ErrUnexpectedEndOfGroupDasigners
|
||||
}
|
||||
depth--
|
||||
case 5:
|
||||
iNdEx += 4
|
||||
default:
|
||||
return 0, fmt.Errorf("proto: illegal wireType %d", wireType)
|
||||
}
|
||||
if iNdEx < 0 {
|
||||
return 0, ErrInvalidLengthDasigners
|
||||
}
|
||||
if depth == 0 {
|
||||
return iNdEx, nil
|
||||
}
|
||||
}
|
||||
return 0, io.ErrUnexpectedEOF
|
||||
}
|
||||
|
||||
var (
|
||||
ErrInvalidLengthDasigners = fmt.Errorf("proto: negative length found during unmarshaling")
|
||||
ErrIntOverflowDasigners = fmt.Errorf("proto: integer overflow")
|
||||
ErrUnexpectedEndOfGroupDasigners = fmt.Errorf("proto: unexpected end of group")
|
||||
)
|
15
x/dasigners/v1/types/errors.go
Normal file
15
x/dasigners/v1/types/errors.go
Normal file
@ -0,0 +1,15 @@
|
||||
package types
|
||||
|
||||
import errorsmod "cosmossdk.io/errors"
|
||||
|
||||
var (
|
||||
ErrSignerExists = errorsmod.Register(ModuleName, 1, "signer exists")
|
||||
ErrEpochNumberNotSet = errorsmod.Register(ModuleName, 2, "epoch number not set")
|
||||
ErrSignerNotFound = errorsmod.Register(ModuleName, 3, "signer not found")
|
||||
ErrInvalidSignature = errorsmod.Register(ModuleName, 4, "invalid signature")
|
||||
ErrQuorumNotFound = errorsmod.Register(ModuleName, 5, "quorum for epoch not found")
|
||||
ErrQuorumIdOutOfBound = errorsmod.Register(ModuleName, 6, "quorum id out of bound")
|
||||
ErrQuorumBitmapLengthMismatch = errorsmod.Register(ModuleName, 7, "quorum bitmap length mismatch")
|
||||
ErrInsufficientBonded = errorsmod.Register(ModuleName, 8, "insufficient bonded amount")
|
||||
ErrRowIndexOutOfBound = errorsmod.Register(ModuleName, 9, "row index out of bound")
|
||||
)
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user