Skip to content

Commit

Permalink
Merge pull request #75 from Agoric/dc-bundle-cost
Browse files Browse the repository at this point in the history
feat(bundle-cost): reduce by 100x as in mainnet 61
  • Loading branch information
dckc authored Mar 6, 2024
2 parents 6c6d459 + 9df5b42 commit 989f22d
Show file tree
Hide file tree
Showing 11 changed files with 1,797 additions and 2 deletions.
7 changes: 6 additions & 1 deletion packages/synthetic-chain/src/cli/dockerfileGen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
encodeUpgradeInfo,
imageNameForProposal,
isPassed,
ParameterChangeProposal,
} from './proposals.js';
import { Platform } from './build.js';

Expand Down Expand Up @@ -96,7 +97,10 @@ RUN ./run_execute.sh
* Run a core-eval proposal
* - Run the core-eval scripts from the proposal. They are only guaranteed to have started, not completed.
*/
EVAL({ path, proposalName }: CoreEvalProposal, lastProposal: ProposalInfo) {
EVAL(
{ path, proposalName }: CoreEvalProposal | ParameterChangeProposal,
lastProposal: ProposalInfo,
) {
return `
# EVAL ${proposalName}
FROM use-${lastProposal.proposalName} as eval-${proposalName}
Expand Down Expand Up @@ -218,6 +222,7 @@ export function writeDockerfile(

switch (proposal.type) {
case '/agoric.swingset.CoreEvalProposal':
case '/cosmos.params.v1beta1.ParameterChangeProposal':
blocks.push(stage.EVAL(proposal, previousProposal!));
break;
case 'Software Upgrade Proposal':
Expand Down
9 changes: 8 additions & 1 deletion packages/synthetic-chain/src/cli/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,14 @@ export type CoreEvalProposal = ProposalCommon & {
}
);

export type ProposalInfo = SoftwareUpgradeProposal | CoreEvalProposal;
export type ParameterChangeProposal = ProposalCommon & {
type: '/cosmos.params.v1beta1.ParameterChangeProposal';
};

export type ProposalInfo =
| SoftwareUpgradeProposal
| CoreEvalProposal
| ParameterChangeProposal;

function readInfo(proposalPath: string): ProposalInfo {
assert(
Expand Down
2 changes: 2 additions & 0 deletions proposals/61:lo-bundle-cost/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
proposer-61.json
tx-hist-proposer-61.json
1 change: 1 addition & 0 deletions proposals/61:lo-bundle-cost/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
27 changes: 27 additions & 0 deletions proposals/61:lo-bundle-cost/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# reverse-engineer Proposal 61: Lower bundle cost

# `agd tx gov submit-proposal param-change` seems
# to JSON.stringify the value in the proposal.
# So we need to `fromjson` it before feeding it back to `agd`.
lower-bundle-cost.json: tx-61.json
jq '.tx.body.messages[0].content | .changes[0].value |= fromjson' tx-61.json >$@

PROPOSAL=61
proposer-61.json:
agd --node $(ARCHIVE_NODE) query gov proposer $(PROPOSAL) -o json >$@

tx-hist-proposer-61.json: proposer-61.json
PROPOSER="$$(jq -r .proposer proposer-61.json)"; \
agd --node $(ARCHIVE_NODE) query txs --events="message.sender=$$PROPOSER" -o json >$@

tx-61.json: tx-hist-proposer-61.json
jq '.txs | .[] | select(.tx.body.messages[0].content["@type"] == "/cosmos.params.v1beta1.ParameterChangeProposal")' \
tx-hist-proposer-61.json >$@

# clean up locally computed files
clean:
rm -f lower-bundle-cost.json

# clean up files cached from the network as well
realclean: clean
rm -f tx-61.json proposer-61.json tx-hist-proposer-61.json
17 changes: 17 additions & 0 deletions proposals/61:lo-bundle-cost/eval.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

# Exit when any command fails
set -e

source /usr/src/upgrade-test-scripts/env_setup.sh

GAS_ADJUSTMENT=1.2
SIGN_BROADCAST_OPTS="--keyring-backend=test --chain-id=$CHAINID \
--gas=auto --gas-adjustment=$GAS_ADJUSTMENT \
--yes -b block"

agd tx gov submit-proposal param-change lower-bundle-cost.json \
$SIGN_BROADCAST_OPTS --from validator

voteLatestProposalAndWait

49 changes: 49 additions & 0 deletions proposals/61:lo-bundle-cost/lower-bundle-cost.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"@type": "/cosmos.params.v1beta1.ParameterChangeProposal",
"title": "Lower Bundle Cost ",
"description": "As developers we continue to build upon Agoric blockchain's capabilities; however, one pressing challenge that our community faces is the high cost associated with installing bundles on-chain.\n\nCurrently, the cost stands at approximately 0.002 IST/byte or $2 per kilobyte (KB) (see [DefaultBeansPerStorageByte parameter](https://github.com/Agoric/agoric-sdk/blob/ac9f916a844f06db1c43e9cc69a948d9c3528a4e/golang/cosmos/x/swingset/types/default-params.go#L51)), a rate that significantly restricts participation and innovation, particularly for developers and projects that require deploying large or numerous smart contracts and applications on Agoric blockchain.\n\nTo address the outlined issues and foster a more inclusive and innovative environment, we’d like to propose reducing the cost of installing a bundle on-chain from $2/KB to $0.02/KB.",
"changes": [
{
"subspace": "swingset",
"key": "beans_per_unit",
"value": [
{
"key": "blockComputeLimit",
"beans": "6500000000"
},
{
"key": "feeUnit",
"beans": "1000000000000"
},
{
"key": "inboundTx",
"beans": "10000000000"
},
{
"key": "message",
"beans": "1000000000"
},
{
"key": "messageByte",
"beans": "20000000"
},
{
"key": "minFeeDebit",
"beans": "200000000000"
},
{
"key": "vatCreation",
"beans": "30000000"
},
{
"key": "xsnapComputron",
"beans": "100"
},
{
"key": "storageByte",
"beans": "20000000"
}
]
}
]
}
17 changes: 17 additions & 0 deletions proposals/61:lo-bundle-cost/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"agoricProposal": {
"type": "/cosmos.params.v1beta1.ParameterChangeProposal"
},
"type": "module",
"license": "Apache-2.0",
"dependencies": {
"@agoric/synthetic-chain": "0.0.7"
},
"scripts": {
"agops": "yarn --cwd /usr/src/agoric-sdk/ --silent agops"
},
"ava": {
"timeout": "30s"
},
"packageManager": "[email protected]"
}
16 changes: 16 additions & 0 deletions proposals/61:lo-bundle-cost/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
set -e

expected=20000000

params="$(agd query swingset params -o json)"
cost="$(echo $params | jq -r ".beans_per_unit | .[] | select(.key == \"storageByte\") | .beans" )"

# fail if cost is not expected
if [ "$cost" != "$expected" ]; then
echo "Expected cost $expected, got $cost"
exit 1
else
echo "Cost is $cost"
fi

Loading

0 comments on commit 989f22d

Please sign in to comment.