Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(bundle-cost): reduce by 100x as in mainnet 61 #75

Merged
merged 6 commits into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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 >$@
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On first read I thought this was able to build dynamically from the ARCHIVE_NODE.

Please comment how this Makefile is intended to be used.

Incidentally, I suggest that lower-bundle-cost.json be produced during the build since it's a fast local operation to create from tx-61.json

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment how this Makefile is intended to be used.

I added some comments. I don't think I quite covered this though. Feel free to add more or discuss it or something.

I suggest that lower-bundle-cost.json be produced during the build ...

I don't have a good sense of how the work should be partitioned in EVAL vs other stuff, so I'll leave this to you.


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why two cleans? please comment

for naming, it's odd to imply that the other isn't real. consider clean-all

but I'd prefer to have lower-bundle-cost.json be produced in the build, in which case there'd be only one target and one clean here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

realclean vs clean is a gnu convention

The difference in this case is: re-fetching from the network is expensive / wasteful while I was rapidly iterating on the jq step.

Will comment...

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