Anastasia-Labs / lucid-evolution

https://anastasia-labs.github.io/lucid-evolution/
47 stars 20 forks source link

Custom Protocol Params #382

Closed mgpai22 closed 3 weeks ago

mgpai22 commented 3 weeks ago

The ability to customize protocol parameters would be really useful for debugging.

I am trying to debug the integration of my aiken contract with off-chain. However, when I add traces, the tx exceeds the default limit of 16kb.

I am just trying to get the evaluation result so this poses a challenge.

My hacky solution is just to make a custom provider. This should be made easier!

const provider = new Blockfrost(BLOCKFROST_URL, BLOCKFROST_KEY)
const lucid = await Lucid(provider, NETWORK);

const customProtocolParameters = {
    ...lucid.config().protocolParameters,
    maxTxSize: 20000,
};

class CustomProvider extends Blockfrost {
    constructor(originalProvider: Blockfrost) {
        super(originalProvider.url, originalProvider.projectId);
    }

    async getProtocolParameters() {
        const baseParams = await super.getProtocolParameters();
        return {
            ...baseParams,
            maxTxSize: 20000,
        };
    }
}

await lucid.switchProvider(new CustomProvider(provider));
keyan-m commented 3 weeks ago

If you use an Emulator, you can already do this: https://github.com/Anastasia-Labs/smart-handles-offchain/blob/988347747e1d3bbb80244781916620db8f2b8d8a/example/test/batch-request-swap.test.ts#L35-L50

mgpai22 commented 3 weeks ago

Excellent!