Skip to content

Commit

Permalink
Merge branch 'CNS-930-begin-block-may-take-too-long' of github.com:la…
Browse files Browse the repository at this point in the history
…vanet/lava into CNS-930-begin-block-may-take-too-long
  • Loading branch information
Yarom Swisa authored and Yarom Swisa committed Apr 3, 2024
2 parents c5127a4 + 817f645 commit 2895ff6
Show file tree
Hide file tree
Showing 2 changed files with 302 additions and 4 deletions.
296 changes: 296 additions & 0 deletions cookbook/plans/gateway.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,296 @@
{
"proposal": {
"title": "Add plan proposal: Gateway",
"description": "A proposal for a new plan for a lava gateway",
"plans": [
{
"index": "gateway",
"description": "Plan for the Lava gateway",
"type": "rpc",
"price": {
"denom": "ulava",
"amount": "1000000000"
},
"allowed_buyers": [
"lava@1x07x0krj7h00jejrcp35kvlc8tpa44dza76dw8"
],
"annual_discount_percentage": 0,
"allow_overuse": false,
"overuse_rate": 0,
"projects": 50,
"plan_policy": {
"geolocation_profile": "GL",
"total_cu_limit": 9223372036854775807,
"epoch_cu_limit": 9223372036854775807,
"max_providers_to_pair": 24,
"selected_providers": [],
"selected_providers_mode": "ALLOWED",
"chain_policies": [
{
"apis": [],
"chain_id": "NEAR",
"requirements": [
{
"collection": {
"add_on": "",
"api_interface": "jsonrpc",
"internal_path": "",
"type": "POST"
},
"extensions": [
"archive"
],
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "STRK",
"requirements": [
{
"collection": {
"add_on": "trace",
"api_interface": "jsonrpc",
"internal_path": "",
"type": "POST"
},
"extensions": [],
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "ETH1",
"requirements": [
{
"collection": {
"add_on": "",
"api_interface": "jsonrpc",
"internal_path": "",
"type": "POST"
},
"extensions": [
"archive"
],
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "EVMOS",
"requirements": [
{
"collection": {
"add_on": "",
"api_interface": "jsonrpc",
"internal_path": "",
"type": "POST"
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "rest",
"internal_path": "",
"type": "GET"
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "grpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "tendermintrpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "AXELAR",
"requirements": [
{
"collection": {
"add_on": "",
"api_interface": "rest",
"internal_path": "",
"type": "GET"
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "tendermintrpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "grpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "OSMOSIS",
"requirements": [
{
"collection": {
"add_on": "",
"api_interface": "rest",
"internal_path": "",
"type": "GET"
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "tendermintrpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "grpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "COSMOSHUB",
"requirements": [
{
"collection": {
"add_on": "",
"api_interface": "rest",
"internal_path": "",
"type": "GET"
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "tendermintrpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
},
{
"collection": {
"add_on": "",
"api_interface": "grpc",
"internal_path": "",
"type": ""
},
"extensions": [
"archive"
],
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "SQDSUBGRAPH",
"requirements": [
{
"collection": {
"api_interface": "rest",
"internal_path": "",
"type": "POST",
"add_on": "compound-v3"
},
"mixed": true
},
{
"collection": {
"api_interface": "rest",
"internal_path": "",
"type": "POST",
"add_on": "aave-v3"
},
"mixed": true
}
]
},
{
"apis": [],
"chain_id": "*",
"requirements": []
}
]
}
}
]
},
"deposit": "10000000ulava"
}
10 changes: 6 additions & 4 deletions x/dualstaking/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAd
// create new delegation period record
// add description
func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) error {
originalGas := ctx.GasMeter().GasConsumed()
originalGasMeter := ctx.GasMeter()
ctx = ctx.WithGasMeter(sdk.NewInfiniteGasMeter())
providers := 0
defer func() {
endGas := ctx.GasMeter().GasConsumed()
if endGas > originalGas && providers < PROVIDERS_NUM_GAS_REFUND {
ctx.GasMeter().RefundGas(endGas-originalGas, "refund hooks gas")
consumedGas := ctx.GasMeter().GasConsumed()
ctx = ctx.WithGasMeter(originalGasMeter)
if providers >= PROVIDERS_NUM_GAS_REFUND {
ctx.GasMeter().ConsumeGas(consumedGas, "consume hooks gas")
}
}()

Expand Down

0 comments on commit 2895ff6

Please sign in to comment.