mirror of
https://github.com/0glabs/0g-chain.git
synced 2025-04-04 15:55:23 +00:00
Merge 18d4e1b538
into dc888ceb78
This commit is contained in:
commit
53074c5040
@ -19,6 +19,7 @@ import (
|
||||
snapshottypes "github.com/cosmos/cosmos-sdk/snapshots/types"
|
||||
"github.com/cosmos/cosmos-sdk/store"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/auth/signing"
|
||||
"github.com/cosmos/cosmos-sdk/x/crisis"
|
||||
ethermintflags "github.com/evmos/ethermint/server/flags"
|
||||
"github.com/spf13/cast"
|
||||
@ -26,6 +27,8 @@ import (
|
||||
|
||||
"github.com/0glabs/0g-chain/app"
|
||||
"github.com/0glabs/0g-chain/app/params"
|
||||
gethtypes "github.com/ethereum/go-ethereum/core/types"
|
||||
evmtypes "github.com/evmos/ethermint/x/evm/types"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -106,7 +109,7 @@ func (ac appCreator) newApp(
|
||||
if appOpts.Get(flagSkipLoadLatest) != nil {
|
||||
skipLoadLatest = cast.ToBool(appOpts.Get(flagSkipLoadLatest))
|
||||
}
|
||||
|
||||
mempoolMaxTxs := cast.ToInt(appOpts.Get(server.FlagMempoolMaxTxs))
|
||||
mempool := app.NewPriorityMempool()
|
||||
|
||||
bApp := app.NewBaseApp(logger, db, ac.encodingConfig,
|
||||
@ -124,6 +127,8 @@ func (ac appCreator) newApp(
|
||||
baseapp.SetIAVLLazyLoading(cast.ToBool(appOpts.Get(server.FlagIAVLLazyLoading))),
|
||||
baseapp.SetChainID(chainID),
|
||||
baseapp.SetMempool(mempool),
|
||||
baseapp.SetMempoolMaxTxs(mempoolMaxTxs),
|
||||
baseapp.SetTxInfoExtracter(extractTxInfo),
|
||||
)
|
||||
bApp.SetTxEncoder(ac.encodingConfig.TxConfig.TxEncoder())
|
||||
abciProposalHandler := app.NewDefaultProposalHandler(mempool, bApp)
|
||||
@ -199,3 +204,52 @@ func accAddressesFromBech32(addresses ...string) ([]sdk.AccAddress, error) {
|
||||
}
|
||||
return decodedAddresses, nil
|
||||
}
|
||||
|
||||
var ErrMustHaveSigner error = errors.New("tx must have at least one signer")
|
||||
|
||||
func extractTxInfo(ctx sdk.Context, tx sdk.Tx) (*sdk.TxInfo, error) {
|
||||
sigs, err := tx.(signing.SigVerifiableTx).GetSignaturesV2()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var sender string
|
||||
var nonce uint64
|
||||
var gasPrice uint64
|
||||
var gasLimit uint64
|
||||
var txType int32
|
||||
|
||||
if len(sigs) == 0 {
|
||||
txType = 1
|
||||
msgs := tx.GetMsgs()
|
||||
if len(msgs) != 1 {
|
||||
return nil, ErrMustHaveSigner
|
||||
}
|
||||
msgEthTx, ok := msgs[0].(*evmtypes.MsgEthereumTx)
|
||||
if !ok {
|
||||
return nil, ErrMustHaveSigner
|
||||
}
|
||||
ethTx := msgEthTx.AsTransaction()
|
||||
signer := gethtypes.NewEIP2930Signer(ethTx.ChainId())
|
||||
ethSender, err := signer.Sender(ethTx)
|
||||
if err != nil {
|
||||
return nil, ErrMustHaveSigner
|
||||
}
|
||||
sender = sdk.AccAddress(ethSender.Bytes()).String()
|
||||
nonce = ethTx.Nonce()
|
||||
gasPrice = ethTx.GasPrice().Uint64()
|
||||
gasLimit = ethTx.Gas()
|
||||
} else {
|
||||
sig := sigs[0]
|
||||
sender = sdk.AccAddress(sig.PubKey.Address()).String()
|
||||
nonce = sig.Sequence
|
||||
}
|
||||
|
||||
return &sdk.TxInfo{
|
||||
SignerAddress: sender,
|
||||
Nonce: nonce,
|
||||
GasLimit: gasLimit,
|
||||
GasPrice: gasPrice,
|
||||
Type: txType,
|
||||
}, nil
|
||||
}
|
||||
|
2
go.mod
2
go.mod
@ -238,7 +238,7 @@ replace (
|
||||
// Use the cosmos keyring code
|
||||
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
|
||||
// Use cometbft fork of tendermint
|
||||
github.com/cometbft/cometbft => github.com/0glabs/cometbft v0.37.9-0glabs.1
|
||||
github.com/cometbft/cometbft => github.com/0glabs/cometbft v0.37.9-0glabs.2
|
||||
github.com/cometbft/cometbft-db => github.com/kava-labs/cometbft-db v0.9.1-kava.2
|
||||
// Use cosmos-sdk fork with backported fix for unsafe-reset-all, staking transfer events, and custom tally handler support
|
||||
// github.com/cosmos/cosmos-sdk => github.com/0glabs/cosmos-sdk v0.46.11-kava.3
|
||||
|
4
go.sum
4
go.sum
@ -209,8 +209,8 @@ filippo.io/edwards25519 v1.0.0 h1:0wAIcmJUqRdI8IJ/3eGi5/HwXZWPujYXXlkrQogz0Ek=
|
||||
filippo.io/edwards25519 v1.0.0/go.mod h1:N1IkdkCkiLB6tki+MYJoSx2JTY9NUlxZE7eHn5EwJns=
|
||||
git.sr.ht/~sircmpwn/getopt v0.0.0-20191230200459-23622cc906b3/go.mod h1:wMEGFFFNuPos7vHmWXfszqImLppbc0wEhh6JBfJIUgw=
|
||||
git.sr.ht/~sircmpwn/go-bare v0.0.0-20210406120253-ab86bc2846d9/go.mod h1:BVJwbDfVjCjoFiKrhkei6NdGcZYpkDkdyCdg1ukytRA=
|
||||
github.com/0glabs/cometbft v0.37.9-0glabs.1 h1:KQJG17Y21suKP3QNICLto4b5Ak73XbSmKxeLbg0ZM68=
|
||||
github.com/0glabs/cometbft v0.37.9-0glabs.1/go.mod h1:j0Q3RqrCd+cztWCugs3obbzC4NyHGBPZZjtm/fWV00I=
|
||||
github.com/0glabs/cometbft v0.37.9-0glabs.2 h1:/2Kz7Gv17u1BJDTonoZaIw4STwy1G+36k41xJ3fvtWM=
|
||||
github.com/0glabs/cometbft v0.37.9-0glabs.2/go.mod h1:j0Q3RqrCd+cztWCugs3obbzC4NyHGBPZZjtm/fWV00I=
|
||||
github.com/0glabs/cosmos-sdk v0.47.10-0glabs.10 h1:NJp0RwczHBO4EvrQdDxxftHOgUDBtNh7M/vpaG7wFtQ=
|
||||
github.com/0glabs/cosmos-sdk v0.47.10-0glabs.10/go.mod h1:KskIVnhXTFqrw7CDccMvx7To5KzUsOomIsQV7sPGOog=
|
||||
github.com/0glabs/ethermint v0.21.0-0g.v3.1.12 h1:IRVTFhDEH2J5w8ywQW7obXQxYhJYib70SNgKqLOXikU=
|
||||
|
Loading…
Reference in New Issue
Block a user