Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
0b79099
Integrate with forked cosmos
codchen Aug 23, 2022
25fc1fa
update local scripts
codchen Aug 24, 2022
7031e02
Implement optimistic processing (#222)
codchen Sep 6, 2022
cdeb5be
Use SR25519 as signing algo (#238)
codchen Sep 9, 2022
ad9ef93
Register accesscontrol module (#257)
BrandonWeng Sep 23, 2022
01929ee
Ante decorator for tx priorities
Kbhat1 Sep 26, 2022
b1fa4e9
Revert "Ante decorator for tx priorities"
Kbhat1 Sep 26, 2022
67aa385
Prioritize ante decorator (#262)
Kbhat1 Sep 26, 2022
e573b4a
[accesscontrol] Add dependency dag (#258)
udpatil Sep 27, 2022
4145336
Use tx digest dissemination binaries (#265)
philipsu522 Sep 29, 2022
eaf6272
Create Channels from DAG (#261)
BrandonWeng Sep 29, 2022
306960d
Update tm and cosmos releases (#267)
philipsu522 Sep 29, 2022
d8e0ca0
Dag optimization (#263)
udpatil Sep 29, 2022
400e9ba
Parallel TX Synchrnous Testing
BrandonWeng Sep 30, 2022
89b216e
Revert "Parallel TX Synchrnous Testing"
BrandonWeng Sep 30, 2022
1ab9fbb
[graph] Add resource hierarchy to dependency graph (#268)
udpatil Oct 3, 2022
1da840f
Fixes for parallel TX and metrics (#272)
BrandonWeng Oct 3, 2022
a37ff56
[graph] Move metric to dag builder helper (#275)
udpatil Oct 3, 2022
ed31869
[app] Add behavior to process blocks with gov txs sync (#276)
udpatil Oct 4, 2022
99a9b5e
Optimize signals (#280)
udpatil Oct 4, 2022
e33966c
Fix for DAG building switch cases (#282)
BrandonWeng Oct 4, 2022
1810cdd
Add gov proposal handler for acl (#277)
BrandonWeng Oct 4, 2022
74637ab
[app] refactored graph into acl module (#286)
udpatil Oct 6, 2022
1a21a06
Cherry-pick loadtesting changes and make a fix for parallel tx (#288)
BrandonWeng Oct 6, 2022
486fb50
Bump sei-cosmos and sei-tendermint for 2.0.0beta (#293)
BrandonWeng Oct 9, 2022
94cd798
Add aclmapping options and mapping folder (#287)
udpatil Oct 10, 2022
82b8294
Add more parallel TX metrics (#296)
BrandonWeng Oct 10, 2022
6ff7282
[ante] Add ante dep generator default behavior (#294)
udpatil Oct 11, 2022
83c4a23
Add msg send dynamic access ops (#303)
BrandonWeng Oct 12, 2022
d509055
Branch another cache for all transactions (#309)
BrandonWeng Oct 17, 2022
69cfe64
Add Gasless decorator back and remove CountTxDecorator (#311)
BrandonWeng Oct 17, 2022
ec0c368
Add dependencies for ante handlers that read/write accounts (#314)
codchen Oct 18, 2022
a1b70c2
Wasm signal (#305)
udpatil Oct 19, 2022
9c201eb
Lazy Deposit All Module Accounts During EndBlock (#313)
BrandonWeng Oct 19, 2022
03fd60f
Wasm gov (#316)
udpatil Oct 19, 2022
75e7b25
Optimize genesis account creation script (#320)
BrandonWeng Oct 20, 2022
dbf18b1
Fix dex module test (#321)
codchen Oct 20, 2022
d8ccad0
Add simple contract for wasm parallelization testing
codchen Oct 20, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions aclmapping/bank/mappings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package aclbankmapping

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper"
acltypes "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
utils "github.com/sei-protocol/sei-chain/aclmapping/utils"
)

var ErrorInvalidMsgType = fmt.Errorf("invalid message received for bank module")

func GetBankDepedencyGenerator() aclkeeper.DependencyGeneratorMap {
dependencyGeneratorMap := make(aclkeeper.DependencyGeneratorMap)

// dex place orders
placeOrdersKey := acltypes.GenerateMessageKey(&banktypes.MsgSend{})
dependencyGeneratorMap[placeOrdersKey] = MsgSendDependencyGenerator

return dependencyGeneratorMap
}

// TODO:: we can make resource types more granular (e.g KV_PARAM or KV_BANK_BALANCE)
func MsgSendDependencyGenerator(keeper aclkeeper.Keeper, ctx sdk.Context, msg sdk.Msg) ([]sdkacltypes.AccessOperation, error) {
msgSend, ok := msg.(*banktypes.MsgSend)
if !ok {
return []sdkacltypes.AccessOperation{}, ErrorInvalidMsgType
}

accessOperations := []sdkacltypes.AccessOperation{
// MsgSend also checks if the coin denom is enabled, but the information is from the params.
// Changing the param would require a gov proposal, which is synchrounos by default

// Checks balance of sender
{
AccessType: sdkacltypes.AccessType_READ,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: utils.GetIdentifierTemplatePerModule(utils.BANK, msgSend.FromAddress),
},
// Reduce the amount from the sender's balance
{
AccessType: sdkacltypes.AccessType_WRITE,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: utils.GetIdentifierTemplatePerModule(utils.BANK, msgSend.FromAddress),
},

// Checks balance for receiver
{
AccessType: sdkacltypes.AccessType_READ,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: utils.GetIdentifierTemplatePerModule(utils.BANK, msgSend.ToAddress),
},
{
AccessType: sdkacltypes.AccessType_WRITE,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: utils.GetIdentifierTemplatePerModule(utils.BANK, msgSend.ToAddress),
},

// Tries to create the reciever's account if it doesn't exist
{
AccessType: sdkacltypes.AccessType_READ,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: utils.GetIdentifierTemplatePerModule(utils.AUTH, msgSend.ToAddress),
},
{
AccessType: sdkacltypes.AccessType_WRITE,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: utils.GetIdentifierTemplatePerModule(utils.AUTH, msgSend.ToAddress),
},

// Last Operation should always be a commit
{
ResourceType: sdkacltypes.ResourceType_ANY,
AccessType: sdkacltypes.AccessType_COMMIT,
IdentifierTemplate: utils.DefaultIDTemplate,
},
}
return accessOperations, nil
}
25 changes: 25 additions & 0 deletions aclmapping/dependency_generator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package aclmapping

import (
aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper"
aclbankmapping "github.com/sei-protocol/sei-chain/aclmapping/bank"
acldexmapping "github.com/sei-protocol/sei-chain/aclmapping/dex"
aclwasmmapping "github.com/sei-protocol/sei-chain/aclmapping/wasm"
)

type CustomDependencyGenerator struct{}

func NewCustomDependencyGenerator() CustomDependencyGenerator {
return CustomDependencyGenerator{}
}

func (customDepGen CustomDependencyGenerator) GetCustomDependencyGenerators() aclkeeper.DependencyGeneratorMap {
dependencyGeneratorMap := make(aclkeeper.DependencyGeneratorMap)

dependencyGeneratorMap.Merge(acldexmapping.GetDexDependencyGenerators())
dependencyGeneratorMap.Merge(aclbankmapping.GetBankDepedencyGenerator())
wasmDependencyGenerators := aclwasmmapping.NewWasmDependencyGenerator()
dependencyGeneratorMap.Merge(wasmDependencyGenerators.GetWasmDependencyGenerators())

return dependencyGeneratorMap
}
34 changes: 34 additions & 0 deletions aclmapping/dex/mappings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package acldexmapping

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper"
acltypes "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"
dexmoduletypes "github.com/sei-protocol/sei-chain/x/dex/types"
)

var ErrPlaceOrdersGenerator = fmt.Errorf("invalid message received for type DexPlaceOrders")

func GetDexDependencyGenerators() aclkeeper.DependencyGeneratorMap {
dependencyGeneratorMap := make(aclkeeper.DependencyGeneratorMap)

// dex place orders
placeOrdersKey := acltypes.GenerateMessageKey(&dexmoduletypes.MsgPlaceOrders{})
dependencyGeneratorMap[placeOrdersKey] = DexPlaceOrdersDependencyGenerator

return dependencyGeneratorMap
}

func DexPlaceOrdersDependencyGenerator(keeper aclkeeper.Keeper, ctx sdk.Context, msg sdk.Msg) ([]sdkacltypes.AccessOperation, error) {
placeOrdersMsg, ok := msg.(*dexmoduletypes.MsgPlaceOrders)
if !ok {
return []sdkacltypes.AccessOperation{}, ErrPlaceOrdersGenerator
}
// TODO: This is not final, JUST AN EXAMPLE
return []sdkacltypes.AccessOperation{
{AccessType: sdkacltypes.AccessType_WRITE, ResourceType: sdkacltypes.ResourceType_KV, IdentifierTemplate: placeOrdersMsg.ContractAddr},
}, nil
}
38 changes: 38 additions & 0 deletions aclmapping/utils/identifier_templates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package util

import (
"fmt"

sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
)

const (
ACCOUNT = "acc"
BANK = "bank"
AUTH = "auth"
DefaultIDTemplate = "*"
)

func GetIdentifierTemplatePerModule(module string, identifier string) string {
return fmt.Sprintf("%s/%s", module, identifier)
}

func GetPrefixedIdentifierTemplatePerModule(module string, identifier string, prefix string) string {
return fmt.Sprintf("%s/%s/%s", module, prefix, identifier)
}

func GetOracleReadAccessOpsForValAndFeeder(feederAddr sdk.Address, valAddr sdk.Address) []sdkacltypes.AccessOperation {
return []sdkacltypes.AccessOperation{
{
AccessType: sdkacltypes.AccessType_READ,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: GetIdentifierTemplatePerModule("oracle", feederAddr.String()),
},
{
AccessType: sdkacltypes.AccessType_READ,
ResourceType: sdkacltypes.ResourceType_KV,
IdentifierTemplate: GetIdentifierTemplatePerModule("oracle", valAddr.String()),
},
}
}
52 changes: 52 additions & 0 deletions aclmapping/wasm/mappings.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package aclwasmmapping

import (
"fmt"

wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkacltypes "github.com/cosmos/cosmos-sdk/types/accesscontrol"
aclkeeper "github.com/cosmos/cosmos-sdk/x/accesscontrol/keeper"
acltypes "github.com/cosmos/cosmos-sdk/x/accesscontrol/types"
)

var (
ErrInvalidWasmExecuteMessage = fmt.Errorf("invalid message received for type WasmExecuteContract")
ErrInvalidWasmFunction = fmt.Errorf("unable to identify wasm function")
ErrWasmFunctionDependenciesDisabled = fmt.Errorf("wasm function dependency mapping disabled")
)

type WasmDependencyGenerator struct{}

func NewWasmDependencyGenerator() WasmDependencyGenerator {
return WasmDependencyGenerator{}
}

func (wasmDepGen WasmDependencyGenerator) GetWasmDependencyGenerators() aclkeeper.DependencyGeneratorMap {
dependencyGeneratorMap := make(aclkeeper.DependencyGeneratorMap)

// wasm execute
executeContractKey := acltypes.GenerateMessageKey(&wasmtypes.MsgExecuteContract{})
dependencyGeneratorMap[executeContractKey] = wasmDepGen.WasmExecuteContractGenerator

return dependencyGeneratorMap
}

func (wasmDepGen WasmDependencyGenerator) WasmExecuteContractGenerator(keeper aclkeeper.Keeper, ctx sdk.Context, msg sdk.Msg) ([]sdkacltypes.AccessOperation, error) {
executeContractMsg, ok := msg.(*wasmtypes.MsgExecuteContract)
if !ok {
return []sdkacltypes.AccessOperation{}, ErrInvalidWasmExecuteMessage
}
contractAddr, err := sdk.AccAddressFromBech32(executeContractMsg.Contract)
if err != nil {
return []sdkacltypes.AccessOperation{}, err
}
wasmDependencyMapping, err := keeper.GetWasmDependencyMapping(ctx, contractAddr)
if err != nil {
return []sdkacltypes.AccessOperation{}, err
}
if !wasmDependencyMapping.Enabled {
return []sdkacltypes.AccessOperation{}, ErrWasmFunctionDependenciesDisabled
}
return wasmDependencyMapping.AccessOps, nil
}
32 changes: 18 additions & 14 deletions app/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,49 +2,53 @@ package app

import (
"context"
"time"

sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/sei-protocol/sei-chain/utils/metrics"
abci "github.com/tendermint/tendermint/abci/types"
"go.opentelemetry.io/otel/attribute"
)

func (app *App) BeginBlock(req abci.RequestBeginBlock) (res abci.ResponseBeginBlock) {
ctx, topSpan := (*app.tracingInfo.Tracer).Start(context.Background(), "Block")
func (app *App) BeginBlock(ctx sdk.Context, req abci.RequestBeginBlock) (res abci.ResponseBeginBlock) {
tracectx, topSpan := (*app.tracingInfo.Tracer).Start(context.Background(), "Block")
topSpan.SetAttributes(attribute.Int64("height", req.Header.Height))
app.tracingInfo.BlockSpan = &topSpan
app.tracingInfo.TracerContext = ctx
app.tracingInfo.TracerContext = tracectx
_, beginBlockSpan := (*app.tracingInfo.Tracer).Start(app.tracingInfo.TracerContext, "BeginBlock")
defer beginBlockSpan.End()
return app.BaseApp.BeginBlock(req)
return app.BaseApp.BeginBlock(ctx, req)
}

func (app *App) EndBlock(req abci.RequestEndBlock) (res abci.ResponseEndBlock) {
func (app *App) EndBlock(ctx sdk.Context, req abci.RequestEndBlock) (res abci.ResponseEndBlock) {
_, span := (*app.tracingInfo.Tracer).Start(app.tracingInfo.TracerContext, "EndBlock")
defer span.End()
return app.BaseApp.EndBlock(req)
return app.BaseApp.EndBlock(ctx, req)
}

func (app *App) CheckTx(req abci.RequestCheckTx) abci.ResponseCheckTx {
func (app *App) CheckTx(ctx context.Context, req *abci.RequestCheckTx) (*abci.ResponseCheckTx, error) {
_, span := (*app.tracingInfo.Tracer).Start(app.tracingInfo.TracerContext, "CheckTx")
defer span.End()
return app.BaseApp.CheckTx(req)
return app.BaseApp.CheckTx(ctx, req)
}

func (app *App) DeliverTx(req abci.RequestDeliverTx) abci.ResponseDeliverTx {
ctx, span := (*app.tracingInfo.Tracer).Start(app.tracingInfo.TracerContext, "DeliverTx")
func (app *App) DeliverTx(ctx sdk.Context, req abci.RequestDeliverTx) abci.ResponseDeliverTx {
defer metrics.MeasureDeliverTxDuration(time.Now())
tracectx, span := (*app.tracingInfo.Tracer).Start(app.tracingInfo.TracerContext, "DeliverTx")
oldCtx := app.tracingInfo.TracerContext
app.tracingInfo.TracerContext = ctx
app.tracingInfo.TracerContext = tracectx
defer span.End()
defer func() { app.tracingInfo.TracerContext = oldCtx }()
return app.BaseApp.DeliverTx(req)
return app.BaseApp.DeliverTx(ctx, req)
}

func (app *App) Commit() (res abci.ResponseCommit) {
func (app *App) Commit(ctx context.Context) (res *abci.ResponseCommit, err error) {
if app.tracingInfo.BlockSpan != nil {
defer (*app.tracingInfo.BlockSpan).End()
}
_, span := (*app.tracingInfo.Tracer).Start(app.tracingInfo.TracerContext, "Commit")
defer span.End()
app.tracingInfo.TracerContext = context.Background()
app.tracingInfo.BlockSpan = nil
return app.BaseApp.Commit()
return app.BaseApp.Commit(ctx)
}
Loading