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

refactor: remove unused milestones #718

Merged
merged 6 commits into from
Sep 30, 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
16 changes: 1 addition & 15 deletions packages/api-http/source/controllers/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,10 @@ export class TransactionsController extends Controller {
return { data: schemasByType };
}

// TODO: Remove endpoint
public async fees(request: Hapi.Request) {
const configuration = await this.getConfiguration();
const {
fees: { staticFees },
} = configuration.activeMilestones;

const transactionTypes = await this.getTransactionTypes();

const typeGroups: Record<string | number, Record<string, number>> = {};

for (const { typeGroup, key } of transactionTypes) {
if (typeGroups[typeGroup] === undefined) {
typeGroups[typeGroup] = {};
}

typeGroups[typeGroup][key] = staticFees[key]?.toFixed() ?? "0";
}

return { data: typeGroups };
}

Expand Down
25 changes: 1 addition & 24 deletions packages/api-http/test/fixtures/node_configuration.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,7 @@
"minimumGasFee": 5,
"minimumGasLimit": 21000,
"maximumGasLimit": 2000000,
"nativeFeeMultiplier": 100,
"nativeGasLimits": {
"transfer": 21000,
"multiPayment": 50000,
"multiSignature": 50000,
"usernameRegistration": 100000,
"usernameResignation": 50000,
"validatorRegistration": 100000,
"validatorResignation": 50000,
"vote": 50000
}
},
"fees": {
"staticFees": {
"multiPayment": 10000000,
"multiSignature": 500000000,
"transfer": 10000000,
"usernameRegistration": 2500000000,
"usernameResignation": 2500000000,
"validatorRegistration": 2500000000,
"validatorResignation": 2500000000,
"vote": 100000000
}
"nativeFeeMultiplier": 100
},
"height": 0,
"reward": "0",
Expand All @@ -50,7 +28,6 @@
"tolerance": 100
},
"activeValidators": 0,
"multiPaymentLimit": 256,
"vendorFieldLength": 255
},
"core": {
Expand Down
14 changes: 1 addition & 13 deletions packages/api-http/test/fixtures/transactions_fees.json
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
{
"1": {
"transfer": "10000000",
"validatorRegistration": "2500000000",
"vote": "100000000",
"multiSignature": "500000000",
"multiPayment": "10000000",
"validatorResignation": "2500000000",
"usernameRegistration": "2500000000",
"usernameResignation": "2500000000",
"evmCall": "0"
}
}
{}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ describe<{
blockTime: 8000,
epoch: match.string,
height: 0,
multiPaymentLimit: 256,
reward: "0",
satoshi: match.object,
vendorFieldLength: 255,
Expand Down Expand Up @@ -208,7 +207,6 @@ describe<{
blockTime: 9000,
epoch: match.string,
height: 0,
multiPaymentLimit: 256,
reward: "0",
satoshi: match.object,
stageTimeoutout: 2000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ describe<{
maximumGasLimit: 2000000,
minimumGasFee: 5,
minimumGasLimit: 21000,
nativeGasLimits: {
transfer: 21000,
multiPayment: 50000,
multiSignature: 50000,
usernameRegistration: 100000,
usernameResignation: 50000,
validatorRegistration: 100000,
validatorResignation: 50000,
vote: 50000,
},
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,8 @@ describe<{
minimumGasLimit: 21_000,
maximumGasLimit: 2_000_000,
nativeFeeMultiplier: 100,
nativeGasLimits: {
transfer: 21_000,
multiPayment: 50_000,
multiSignature: 50_000,
usernameRegistration: 100_000,
usernameResignation: 50_000,
validatorRegistration: 100_000,
validatorResignation: 50_000,
vote: 50_000,
},
},
fees: {
staticFees: {
multiPayment: 10_000_000,
multiSignature: 500_000_000,
transfer: 10_000_000,
usernameRegistration: 2_500_000_000,
usernameResignation: 2_500_000_000,
validatorRegistration: 2_500_000_000,
validatorResignation: 2_500_000_000,
vote: 100_000_000,
},
},
height: 0,
multiPaymentLimit: 256,
reward: "0",
satoshi: {
decimals: 18,
Expand Down
23 changes: 0 additions & 23 deletions packages/configuration-generator/source/generators/milestones.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,13 @@ export class MilestonesGenerator {
},
epoch: options.epoch.toISOString().slice(0, 11) + "00:00:00.000Z",
evmSpec: Contracts.Evm.SpecId.SHANGHAI,
fees: {
staticFees: {
multiPayment: 10_000_000,
multiSignature: 500_000_000,
transfer: 10_000_000,
usernameRegistration: 2_500_000_000,
usernameResignation: 2_500_000_000,
validatorRegistration: 2_500_000_000,
validatorResignation: 2_500_000_000,
vote: 100_000_000,
},
},
gas: {
maximumGasLimit: 2_000_000,
minimumGasFee: 5,
minimumGasLimit: 21_000,
nativeFeeMultiplier: 100,
nativeGasLimits: {
multiPayment: 50_000,
multiSignature: 50_000,
transfer: 21_000,
usernameRegistration: 100_000,
usernameResignation: 50_000,
validatorRegistration: 100_000,
validatorResignation: 50_000,
vote: 50_000,
},
},
height: 0,
multiPaymentLimit: 256,
reward: "0",
satoshi: {
decimals: 18,
Expand Down
4 changes: 0 additions & 4 deletions packages/contracts/source/contracts/crypto/networks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { SpecId } from "../evm/evm.js";
import { Fees } from "../fees.js";
import { CommitJson } from "./commit.js";

export type NetworkConfig = {
Expand Down Expand Up @@ -51,7 +50,6 @@ export type MilestoneGas = {
maximumGasLimit: number;
minimumGasFee: number;
nativeFeeMultiplier: number;
nativeGasLimits: Record<string, number>;
};

export type Milestone = {
Expand All @@ -62,8 +60,6 @@ export type Milestone = {
epoch: string;
evmSpec: SpecId;
gas: MilestoneGas;
fees: Fees;
multiPaymentLimit: number;
reward: string;
satoshi: MilestoneSatoshi;
timeouts: MilestoneTimeouts;
Expand Down
12 changes: 0 additions & 12 deletions packages/contracts/source/contracts/fees.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/contracts/source/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ export * as ConsensusStorage from "./consensus-storage.js";
export * as Crypto from "./crypto/index.js";
export * as Database from "./database.js";
export * as Evm from "./evm/index.js";
export * as Fee from "./fees.js";
export * as Kernel from "./kernel/index.js";
export * as NetworkGenerator from "./network-generator.js";
export * as P2P from "./p2p/index.js";
Expand Down
25 changes: 1 addition & 24 deletions packages/core/bin/config/testnet/core/crypto.json
Original file line number Diff line number Diff line change
Expand Up @@ -3217,36 +3217,13 @@
},
"epoch": "2024-09-19T00:00:00.000Z",
"evmSpec": "Shanghai",
"fees": {
"staticFees": {
"multiPayment": 10000000,
"multiSignature": 500000000,
"transfer": 10000000,
"usernameRegistration": 2500000000,
"usernameResignation": 2500000000,
"validatorRegistration": 2500000000,
"validatorResignation": 2500000000,
"vote": 100000000
}
},
"gas": {
"maximumGasLimit": 2000000,
"minimumGasFee": 5,
"minimumGasLimit": 21000,
"nativeFeeMultiplier": 100,
"nativeGasLimits": {
"multiPayment": 50000,
"multiSignature": 50000,
"transfer": 21000,
"usernameRegistration": 100000,
"usernameResignation": 50000,
"validatorRegistration": 100000,
"validatorResignation": 50000,
"vote": 50000
}
"nativeFeeMultiplier": 100
},
"height": 0,
"multiPaymentLimit": 256,
"reward": "0",
"satoshi": {
"decimals": 18,
Expand Down
2 changes: 0 additions & 2 deletions packages/core/source/commands/config-generate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ describe<{
blockTime: 9000,
epoch: match.string,
height: 0,
multiPaymentLimit: 256,
reward: "0",
satoshi: match.object,
vendorFieldLength: 255,
Expand Down Expand Up @@ -379,7 +378,6 @@ describe<{
blockTime: 9000,
epoch: match.string,
height: 0,
multiPaymentLimit: 256,
reward: "0", // TODO: Check
satoshi: match.object,
vendorFieldLength: 64,
Expand Down
6 changes: 0 additions & 6 deletions packages/crypto-config/source/configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ describe<{
gas: cryptoJson.milestones[0].gas,
epoch: cryptoJson.milestones[0].epoch,
evmSpec: cryptoJson.milestones[0].evmSpec,
fees: cryptoJson.milestones[0].fees,
height: 0,
multiPaymentLimit: 256,
reward: "0",
satoshi: { decimals: 18, denomination: 1e18 },
timeouts: {
Expand All @@ -59,9 +57,7 @@ describe<{
gas: cryptoJson.milestones[0].gas,
epoch: cryptoJson.milestones[0].epoch,
evmSpec: cryptoJson.milestones[0].evmSpec,
fees: cryptoJson.milestones[0].fees,
height: 1,
multiPaymentLimit: 256,
reward: "0",
satoshi: { decimals: 18, denomination: 1e18 },
timeouts: {
Expand All @@ -79,9 +75,7 @@ describe<{
gas: cryptoJson.milestones[0].gas,
epoch: cryptoJson.milestones[0].epoch,
evmSpec: cryptoJson.milestones[0].evmSpec,
fees: cryptoJson.milestones[0].fees,
height: 75_600,
multiPaymentLimit: 256,
reward: "2000000000000000000",
satoshi: { decimals: 18, denomination: 1e18 },
timeouts: {
Expand Down
33 changes: 3 additions & 30 deletions packages/evm-gas-fee/source/gas-limits.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,13 @@
import { inject, injectable } from "@mainsail/container";
import { Contracts, Identifiers } from "@mainsail/contracts";
import { Utils } from "@mainsail/kernel";
import { injectable } from "@mainsail/container";
import { Contracts, Exceptions } from "@mainsail/contracts";

@injectable()
export class GasLimits implements Contracts.Evm.GasLimits {
@inject(Identifiers.Cryptography.Configuration)
private readonly configuration!: Contracts.Crypto.Configuration;

public of(transaction: Contracts.Crypto.Transaction): number {
if (transaction.data.asset?.evmCall) {
return transaction.data.asset.evmCall.gasLimit;
}

if (!this.#isNativeType(transaction.type)) {
throw new Error("must be native type");
}

// TODO: take vendorField, multiSig, asset size into account
const { gas: gasConfig } = this.configuration.getMilestone();
const nativeGasLimit = gasConfig.nativeGasLimits[transaction.key];
Utils.assert.defined<number>(nativeGasLimit);
return nativeGasLimit;
throw new Exceptions.TransactionTypeError(transaction.type.toString());
}

#isNativeType(transactionType: Contracts.Crypto.TransactionType): boolean {
return this.#nativeTransactionTypes.has(transactionType);
}

#nativeTransactionTypes = new Set([
Contracts.Crypto.TransactionType.Transfer,
Contracts.Crypto.TransactionType.ValidatorRegistration,
Contracts.Crypto.TransactionType.Vote,
Contracts.Crypto.TransactionType.MultiSignature,
Contracts.Crypto.TransactionType.MultiPayment,
Contracts.Crypto.TransactionType.ValidatorResignation,
Contracts.Crypto.TransactionType.UsernameRegistration,
Contracts.Crypto.TransactionType.UsernameResignation,
]);
}
2 changes: 0 additions & 2 deletions packages/kernel/test/stubs/config-with-crypto/crypto.json
Original file line number Diff line number Diff line change
Expand Up @@ -1831,7 +1831,6 @@
"epoch": "2022-03-10T00:00:00.000Z",
"evmSpec": "Shanghai",
"height": 1,
"multiPaymentLimit": 256,
"reward": "0",
"satoshi": {
"decimals": 8,
Expand All @@ -1853,7 +1852,6 @@
"epoch": "2022-03-10T00:00:00.000Z",
"evmSpec": "Shanghai",
"height": 75600,
"multiPaymentLimit": 256,
"reward": "200000000",
"satoshi": {
"decimals": 8,
Expand Down
Loading
Loading