refactor(auth): decouple auth from x/accounts account abstraction types (#20875)
This commit is contained in:
parent
3ec041e535
commit
acfd1ac30a
@ -30,7 +30,6 @@ require (
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
1
go.mod
1
go.mod
@ -69,7 +69,6 @@ require (
|
||||
require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
filippo.io/edwards25519 v1.1.0 // indirect
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
github.com/DataDog/datadog-go v4.8.3+incompatible // indirect
|
||||
|
||||
@ -54,7 +54,6 @@ require (
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/math v1.3.0 // indirect
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/tx v0.13.3 // indirect
|
||||
|
||||
@ -43,9 +43,8 @@ func TestBaseAccount(t *testing.T) {
|
||||
|
||||
func sendTx(t *testing.T, ctx sdk.Context, app *simapp.SimApp, sender []byte, msg sdk.Msg) {
|
||||
tx := sign(t, ctx, app, sender, privKey, msg)
|
||||
res, _, err := app.SimDeliver(app.TxEncode, tx)
|
||||
_, _, err := app.SimDeliver(app.TxEncode, tx)
|
||||
require.NoError(t, err)
|
||||
t.Log(res)
|
||||
}
|
||||
|
||||
func sign(t *testing.T, ctx sdk.Context, app *simapp.SimApp, from sdk.AccAddress, privKey cryptotypes.PrivKey, msg sdk.Msg) sdk.Tx {
|
||||
|
||||
@ -241,6 +241,7 @@ replace (
|
||||
cosmossdk.io/core/testing => ../core/testing
|
||||
cosmossdk.io/depinject => ../depinject
|
||||
cosmossdk.io/log => ../log
|
||||
cosmossdk.io/store => ../store
|
||||
cosmossdk.io/x/accounts => ../x/accounts
|
||||
cosmossdk.io/x/accounts/defaults/lockup => ../x/accounts/defaults/lockup
|
||||
cosmossdk.io/x/auth => ../x/auth
|
||||
|
||||
@ -196,8 +196,6 @@ cosmossdk.io/errors v1.0.1 h1:bzu+Kcr0kS/1DuPBtUFdWjzLqyUuCiyHjyJB6srBV/0=
|
||||
cosmossdk.io/errors v1.0.1/go.mod h1:MeelVSZThMi4bEakzhhhE/CKqVv3nOJDA25bIqRDu/U=
|
||||
cosmossdk.io/math v1.3.0 h1:RC+jryuKeytIiictDslBP9i1fhkVm6ZDmZEoNP316zE=
|
||||
cosmossdk.io/math v1.3.0/go.mod h1:vnRTxewy+M7BtXBNFybkuhSH4WfedVAAnERHgVFhp3k=
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc h1:R9O9d75e0qZYUsVV0zzi+D7cNLnX2JrUOQNoIPaF0Bg=
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc/go.mod h1:amTTatOUV3u1PsKmNb87z6/galCxrRbz9kRdJkL0DyU=
|
||||
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
|
||||
filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA=
|
||||
filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4=
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
aa_interface_v1 "cosmossdk.io/x/accounts/interfaces/account_abstraction/v1"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/types/address"
|
||||
"github.com/cosmos/cosmos-sdk/types/tx"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -37,8 +38,14 @@ func (k Keeper) IsAbstractedAccount(ctx context.Context, addr []byte) (bool, err
|
||||
return impl.HasExec(&aa_interface_v1.MsgAuthenticate{}), nil
|
||||
}
|
||||
|
||||
func (k Keeper) AuthenticateAccount(ctx context.Context, addr []byte, msg *aa_interface_v1.MsgAuthenticate) error {
|
||||
_, err := k.Execute(ctx, addr, address.Module("accounts"), msg, nil)
|
||||
func (k Keeper) AuthenticateAccount(ctx context.Context, signer []byte, bundler string, rawTx *tx.TxRaw, protoTx *tx.Tx, signIndex uint32) error {
|
||||
msg := &aa_interface_v1.MsgAuthenticate{
|
||||
Bundler: bundler,
|
||||
RawTx: rawTx,
|
||||
Tx: protoTx,
|
||||
SignerIndex: signIndex,
|
||||
}
|
||||
_, err := k.Execute(ctx, signer, address.Module("accounts"), msg, nil)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: %w", ErrAuthentication, err)
|
||||
}
|
||||
|
||||
@ -13,7 +13,6 @@ import (
|
||||
"cosmossdk.io/core/transaction"
|
||||
errorsmod "cosmossdk.io/errors"
|
||||
storetypes "cosmossdk.io/store/types"
|
||||
aa_interface_v1 "cosmossdk.io/x/accounts/interfaces/account_abstraction/v1"
|
||||
authsigning "cosmossdk.io/x/auth/signing"
|
||||
"cosmossdk.io/x/auth/types"
|
||||
txsigning "cosmossdk.io/x/tx/signing"
|
||||
@ -52,7 +51,7 @@ type SignatureVerificationGasConsumer = func(meter storetypes.GasMeter, sig sign
|
||||
|
||||
type AccountAbstractionKeeper interface {
|
||||
IsAbstractedAccount(ctx context.Context, addr []byte) (bool, error)
|
||||
AuthenticateAccount(ctx context.Context, addr []byte, msg *aa_interface_v1.MsgAuthenticate) error
|
||||
AuthenticateAccount(ctx context.Context, signer []byte, bundler string, rawTx *tx.TxRaw, protoTx *tx.Tx, signIndex uint32) error
|
||||
}
|
||||
|
||||
// SigVerificationDecorator verifies all signatures for a tx and returns an
|
||||
@ -434,16 +433,21 @@ func (svd SigVerificationDecorator) authenticateAbstractedAccount(ctx sdk.Contex
|
||||
}
|
||||
|
||||
infoTx := authTx.(interface {
|
||||
GetRawTx() *tx.TxRaw
|
||||
GetProtoTx() *tx.Tx
|
||||
AsTxRaw() (*tx.TxRaw, error)
|
||||
AsTx() (*tx.Tx, error)
|
||||
})
|
||||
|
||||
return svd.aaKeeper.AuthenticateAccount(ctx, signer, &aa_interface_v1.MsgAuthenticate{
|
||||
Bundler: selfBundler,
|
||||
RawTx: infoTx.GetRawTx(),
|
||||
Tx: infoTx.GetProtoTx(),
|
||||
SignerIndex: uint32(index),
|
||||
})
|
||||
txRaw, err := infoTx.AsTxRaw()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get raw tx: %w", err)
|
||||
}
|
||||
|
||||
protoTx, err := infoTx.AsTx()
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to get proto tx: %w", err)
|
||||
}
|
||||
|
||||
return svd.aaKeeper.AuthenticateAccount(ctx, signer, selfBundler, txRaw, protoTx, uint32(index))
|
||||
}
|
||||
|
||||
// ValidateSigCountDecorator takes in Params and returns errors if there are too many signatures in the tx for the given params
|
||||
|
||||
@ -11,7 +11,6 @@ require (
|
||||
cosmossdk.io/errors v1.0.1
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/x/tx v0.13.3
|
||||
github.com/cometbft/cometbft v1.0.0-rc1
|
||||
|
||||
@ -11,7 +11,6 @@ require (
|
||||
cosmossdk.io/log v1.3.1
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/x/tx v0.13.3
|
||||
|
||||
@ -11,7 +11,6 @@ require (
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
||||
github.com/cometbft/cometbft v1.0.0-rc1
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.5
|
||||
|
||||
@ -24,7 +24,6 @@ require (
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/math v1.3.0 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -26,7 +26,6 @@ require (
|
||||
cosmossdk.io/errors v1.0.1 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/math v1.3.0 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -38,7 +38,6 @@ require (
|
||||
require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/tx v0.13.3 // indirect
|
||||
|
||||
@ -23,7 +23,6 @@ require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/math v1.3.0 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -28,7 +28,6 @@ require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -31,7 +31,6 @@ require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/protocolpool v0.0.0-20230925135524-a1bc045b3190 // indirect
|
||||
|
||||
@ -12,7 +12,6 @@ require (
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -11,7 +11,6 @@ require (
|
||||
cosmossdk.io/log v1.3.1
|
||||
cosmossdk.io/math v1.3.0
|
||||
cosmossdk.io/store v1.1.1-0.20240418092142-896cdf1971bc
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/epochs v0.0.0-20240522060652-a1ae4c3e0337
|
||||
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 // indirect
|
||||
github.com/cosmos/cosmos-proto v1.0.0-beta.5
|
||||
|
||||
@ -25,7 +25,6 @@ require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/collections v0.4.0 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -29,7 +29,6 @@ require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/collections v0.4.0 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/auth v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -28,7 +28,6 @@ require (
|
||||
require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
|
||||
@ -30,7 +30,6 @@ require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
buf.build/gen/go/cosmos/gogo-proto/protocolbuffers/go v1.34.2-20240130113600-88ef6483f90f.2 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/tx v0.13.3 // indirect
|
||||
|
||||
@ -158,7 +158,6 @@ require (
|
||||
require (
|
||||
buf.build/gen/go/cometbft/cometbft/protocolbuffers/go v1.34.2-20240701160653-fedbb9acfd2f.2 // indirect
|
||||
cosmossdk.io/log v1.3.1 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/consensus v0.0.0-00010101000000-000000000000
|
||||
github.com/cosmos/crypto v0.1.1 // indirect
|
||||
github.com/dgraph-io/badger/v4 v4.2.0 // indirect
|
||||
|
||||
@ -44,7 +44,6 @@ require (
|
||||
cloud.google.com/go/storage v1.42.0 // indirect
|
||||
cosmossdk.io/collections v0.4.0 // indirect
|
||||
cosmossdk.io/math v1.3.0 // indirect
|
||||
cosmossdk.io/x/accounts v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/bank v0.0.0-20240226161501-23359a0b6d91 // indirect
|
||||
cosmossdk.io/x/staking v0.0.0-00010101000000-000000000000 // indirect
|
||||
cosmossdk.io/x/tx v0.13.3 // indirect
|
||||
|
||||
Loading…
Reference in New Issue
Block a user