-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixup! recovered files needed for CI
- Loading branch information
Showing
8 changed files
with
296 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
// @ts-check | ||
import '@endo/init'; | ||
import { makeNodeBundleCache } from '@endo/bundle-source/cache.js'; | ||
|
||
const trace = (...msgs) => console.log('[rollup-plugin-core-eval]', ...msgs); | ||
|
||
export const coreEvalGlobals = { | ||
E: 'E', | ||
Far: 'Far', | ||
}; | ||
|
||
const redactImportDecls = txt => | ||
txt.replace(/^\s*import\b\s*(.*)/gm, '// XMPORT: $1'); | ||
const omitExportKewords = txt => txt.replace(/^\s*export\b\s*/gm, ''); | ||
// cf. ses rejectImportExpressions | ||
// https://github.com/endojs/endo/blob/ebc8f66e9498f13085a8e64e17fc2f5f7b528faa/packages/ses/src/transforms.js#L143 | ||
const hideImportExpr = txt => txt.replace(/\bimport\b/g, 'XMPORT'); | ||
|
||
export const moduleToScript = () => ({ | ||
name: 'module-to-script', | ||
generateBundle: (_opts, bundle, _isWrite) => { | ||
for (const fileName of Object.keys(bundle)) { | ||
bundle[fileName].code = hideImportExpr( | ||
redactImportDecls(omitExportKewords(bundle[fileName].code)), | ||
); | ||
} | ||
}, | ||
}); | ||
|
||
export const configureOptions = ({ options }) => { | ||
const pattern = new RegExp(`options: Fail.*`, 'g'); | ||
const replacement = `options: ${JSON.stringify(options)},`; | ||
return { | ||
name: 'configureOptions', | ||
transform: async (code, _id) => { | ||
const revised = code.replace(pattern, replacement); | ||
if (revised === code) return null; | ||
return { code: revised }; | ||
}, | ||
}; | ||
}; | ||
|
||
export const configureBundleID = ({ name, rootModule, cache }) => { | ||
// const pattern = new RegExp(`^ *bundleID\\b = Fail.*`); | ||
// const pattern = new RegExp(`Fail\``); | ||
// const pattern = /Fail`no bundleID`/ | ||
const pattern = new RegExp(`bundleID\\b = Fail.*`); | ||
const bundleCacheP = makeNodeBundleCache(cache, {}, s => import(s)); | ||
return { | ||
name: 'configureBundleID', | ||
transform: async (code, _id) => { | ||
trace('transform', name, code, _id); | ||
// passes in code | ||
const bundle = await bundleCacheP.then(c => | ||
c.load(rootModule, name, trace, { elideComments: true }), | ||
); | ||
trace(bundle.endoZipBase64Sha512); | ||
trace('rootModule: ', rootModule); | ||
trace('name: ', name); | ||
const test = JSON.stringify(`z${bundle.endoZipBase64Sha512}`); | ||
trace(test); | ||
const revised = code.replace( | ||
pattern, | ||
`bundleID = ${JSON.stringify(`b1-${bundle.endoZipBase64Sha512}`)}`, | ||
// test, | ||
// () => `b1-${test}` | ||
); | ||
trace('revised === code:', revised === code); | ||
if (revised === code) return null; | ||
return { code: revised }; | ||
}, | ||
}; | ||
}; | ||
|
||
export const emitPermit = ({ permit, file }) => ({ | ||
name: 'emit-permit', | ||
generateBundle(_opts, _bundle) { | ||
this.emitFile({ | ||
type: 'asset', | ||
fileName: file, | ||
source: JSON.stringify(permit, null, 2), | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const ambientSetTimeout = globalThis.setTimeout; | ||
|
||
const sleep = (ms, { log = msg => {}, setTimeout = ambientSetTimeout } = {}) => | ||
new Promise(resolve => { | ||
log(`Sleeping for ${ms}ms...`); | ||
setTimeout(resolve, ms); | ||
}); | ||
|
||
const retryUntilCondition = async ( | ||
operation, | ||
condition, | ||
message, | ||
{ | ||
maxRetries = 6, | ||
retryIntervalMs = 3500, | ||
log = msg => {}, | ||
setTimeout = ambientSetTimeout, | ||
} = {}, | ||
) => { | ||
console.log({ maxRetries, retryIntervalMs, message }); | ||
let retries = 0; | ||
|
||
while (retries < maxRetries) { | ||
try { | ||
const result = await operation(); | ||
if (condition(result)) { | ||
return result; | ||
} | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
log(`Error: ${error.message}`); | ||
} else { | ||
log(`Unknown error: ${String(error)}`); | ||
} | ||
} | ||
|
||
retries++; | ||
console.log( | ||
`Retry ${retries}/${maxRetries} - Waiting for ${retryIntervalMs}ms for ${message}...`, | ||
); | ||
await sleep(retryIntervalMs, { log, setTimeout }); | ||
} | ||
|
||
throw new Error(`${message} condition failed after ${maxRetries} retries.`); | ||
}; | ||
|
||
const makeRetryUntilCondition = (defaultOptions = {}) => { | ||
return (operation, condition, message, options) => | ||
retryUntilCondition(operation, condition, message, { | ||
...defaultOptions, | ||
...options, | ||
}); | ||
}; | ||
|
||
export { sleep, makeRetryUntilCondition }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// @ts-check | ||
|
||
import { Far } from '@endo/far'; | ||
import { makeTracer } from '../src/debug.js'; | ||
|
||
const trace = makeTracer('startOrch'); | ||
|
||
/** @param {BootstrapPowers} powers */ | ||
export const startOrchCoreEval = async ({ | ||
produce: { | ||
cosmosInterchainService, | ||
localchain, | ||
chainTimerService, | ||
chainStorage, | ||
agoricNames, | ||
}, | ||
}) => { | ||
trace('startOrchCoreEval'); | ||
cosmosInterchainService.resolve(Far('DummyOrchestration')); | ||
localchain.resolve(Far('DummyLocalchain')); | ||
chainTimerService.resolve(Far('DummyTimer')); | ||
chainStorage.resolve(Far('DummyStorageNode')); | ||
agoricNames.resolve(Far('agoricNames')); | ||
trace('startOrchCoreEval done'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// @ts-check | ||
import { E, Far } from '@endo/far'; | ||
|
||
/** | ||
* @import {ERef} from '@endo/far'; | ||
* @import {NameHub} from '@agoric/vats'; | ||
*/ | ||
|
||
/** @param {{ queryData: (path: string) => any }} qt */ | ||
export const makeAgoricNames = async qt => { | ||
assert(qt); | ||
const nameHubCache = new Map(); | ||
|
||
/** @param {string} kind */ | ||
const lookupKind = async kind => { | ||
assert.typeof(kind, 'string'); | ||
if (nameHubCache.has(kind)) { | ||
return nameHubCache.get(kind); | ||
} | ||
const entries = await qt.queryData(`published.agoricNames.${kind}`); | ||
const record = Object.fromEntries(entries); | ||
const hub = Far('NameHub', { | ||
lookup: name => record[name], | ||
keys: () => entries.map(e => e[0]), | ||
entries: () => entries, | ||
}); | ||
nameHubCache.set(kind, hub); | ||
return hub; | ||
}; | ||
|
||
const invalidate = () => { | ||
nameHubCache.clear(); | ||
}; | ||
|
||
const hub0 = Far('Hub', { | ||
lookup: async (kind, ...more) => { | ||
const hub2 = lookupKind(kind); | ||
if (more.length > 0) { | ||
return E(hub2).lookup(...more); | ||
} | ||
return hub2; | ||
}, | ||
}); | ||
|
||
return { lookup: hub0.lookup, invalidate }; | ||
}; | ||
const pmethods = harden(['then', 'catch', 'finally']); | ||
// See also: https://github.com/endojs/endo/tree/mfig-o/packages/o | ||
/** @param {ERef<Pick<NameHub, 'lookup'>>} nodeP */ | ||
|
||
export const makeNameProxy = nodeP => | ||
new Proxy(nodeP, { | ||
get(target, prop, _rx) { | ||
assert.typeof(prop, 'string'); | ||
if (pmethods.includes(prop)) { | ||
return target[prop].bind(target); | ||
} | ||
return makeNameProxy(E(target).lookup(prop)); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/bin/bash | ||
|
||
## see https://github.com/cosmology-tech/starship/blob/1d60f55c631b4d0f92a43ad92e9a935298aa3aa5/starship/charts/devnet/scripts/default/update-config.sh | ||
|
||
CHAIN_ID="${CHAIN_ID:=osmosis}" | ||
CHAIN_DIR="${CHAIN_DIR:=$HOME/.osmosisd}" | ||
KEYS_CONFIG="${KEYS_CONFIG:=configs/keys.json}" | ||
|
||
set -eux | ||
|
||
ls $CHAIN_DIR | ||
|
||
echo "Update config.toml file" | ||
sed -i -e 's#"tcp://127.0.0.1:26657"#"tcp://0.0.0.0:26657"#g' $CHAIN_DIR/config/config.toml | ||
sed -i -e 's/index_all_keys = false/index_all_keys = true/g' $CHAIN_DIR/config/config.toml | ||
sed -i -e 's/seeds = ".*"/seeds = ""/g' $CHAIN_DIR/config/config.toml | ||
sed -i -e 's#cors_allowed_origins = \[\]#cors_allowed_origins = \["*"\]#g' $CHAIN_DIR/config/config.toml | ||
|
||
echo "Update client.toml file" | ||
sed -i -e 's#keyring-backend = "os"#keyring-backend = "test"#g' $CHAIN_DIR/config/client.toml | ||
sed -i -e 's#output = "text"#output = "json"#g' $CHAIN_DIR/config/client.toml | ||
sed -i -e "s#chain-id = \"\"#chain-id = \"$CHAIN_ID\"#g" $CHAIN_DIR/config/client.toml | ||
|
||
echo "Update app.toml file" | ||
sed -i -e "s#minimum-gas-prices = \".*\"#minimum-gas-prices = \"0$DENOM\"#g" $CHAIN_DIR/config/app.toml | ||
sed -i -e "s#pruning = \".*\"#pruning = \"default\"#g" $CHAIN_DIR/config/app.toml | ||
sed -i -e 's#enabled-unsafe-cors = false#enabled-unsafe-cors = true#g' $CHAIN_DIR/config/app.toml | ||
sed -i -e 's#swagger = false#swagger = true#g' $CHAIN_DIR/config/app.toml | ||
sed -i -e 's/enable-unsafe-cors = false/enable-unsafe-cors = true/g' $CHAIN_DIR/config/app.toml | ||
sed -i -e 's/enabled-unsafe-cors = false/enabled-unsafe-cors = true/g' $CHAIN_DIR/config/app.toml | ||
|
||
function get_next_line_number() { | ||
local txt=$1 | ||
local file=$2 | ||
local line_number=$(grep -n "$txt" $file | cut -d: -f1 | head -1) | ||
echo $((line_number + 1)) | ||
} | ||
|
||
line_number=$(get_next_line_number "Enable defines if the API server should be enabled." $CHAIN_DIR/config/app.toml) | ||
sed -i -e "${line_number}s/enable = false/enable = true/g" $CHAIN_DIR/config/app.toml | ||
|
||
line_number=$(get_next_line_number "Address defines the API server to listen on." $CHAIN_DIR/config/app.toml) | ||
sed -i -e "${line_number}s#address = \".*\"#address = \"tcp://0.0.0.0:1317\"#g" $CHAIN_DIR/config/app.toml | ||
|
||
line_number=$(get_next_line_number "Enable defines if the gRPC server should be enabled." $CHAIN_DIR/config/app.toml) | ||
sed -i -e "${line_number}s/enable = false/enable = true/g" $CHAIN_DIR/config/app.toml | ||
|
||
line_number=$(get_next_line_number "Address defines the gRPC server address to bind to." $CHAIN_DIR/config/app.toml) | ||
sed -i -e "${line_number}s#address = \".*\"#address = \"0.0.0.0:9090\"#g" $CHAIN_DIR/config/app.toml | ||
|
||
if [ "$METRICS" == "true" ]; then | ||
line_number=$(get_next_line_number "other sinks such as Prometheus." $CHAIN_DIR/config/app.toml) | ||
sed -i -e "${line_number}s/enabled = false/enabled = true/g" $CHAIN_DIR/config/app.toml | ||
|
||
line_number=$(get_next_line_number "PrometheusRetentionTime, when positive, enables a Prometheus metrics sink." $CHAIN_DIR/config/app.toml) | ||
sed -i -e "${line_number}s/prometheus-retention-time = 0/prometheus-retention-time = 3600/g" $CHAIN_DIR/config/app.toml | ||
fi | ||
|
||
echo "Update consensus params in config.toml" | ||
sed -i -e "s#timeout_propose = \".*\"#timeout_propose = \"$TIMEOUT_PROPOSE\"#g" $CHAIN_DIR/config/config.toml | ||
sed -i -e "s#timeout_propose_delta = \".*\"#timeout_propose_delta = \"$TIMEOUT_PROPOSE_DELTA\"#g" $CHAIN_DIR/config/config.toml | ||
sed -i -e "s#timeout_prevote = \".*\"#timeout_prevote = \"$TIMEOUT_PREVOTE\"#g" $CHAIN_DIR/config/config.toml | ||
sed -i -e "s#timeout_prevote_delta = \".*\"#timeout_prevote_delta = \"$TIMEOUT_PREVOTE_DELTA\"#g" $CHAIN_DIR/config/config.toml | ||
sed -i -e "s#timeout_precommit = \".*\"#timeout_precommit = \"$TIMEOUT_PRECOMMIT\"#g" $CHAIN_DIR/config/config.toml | ||
sed -i -e "s#timeout_precommit_delta = \".*\"#timeout_precommit_delta = \"$TIMEOUT_PRECOMMIT_DELTA\"#g" $CHAIN_DIR/config/config.toml | ||
sed -i -e "s#timeout_commit = \".*\"#timeout_commit = \"$TIMEOUT_COMMIT\"#g" $CHAIN_DIR/config/config.toml | ||
|
||
if [ "$METRICS" == "true" ]; then | ||
sed -i -e "s/prometheus = false/prometheus = true/g" $CHAIN_DIR/config/config.toml | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters