Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@

CREATE INDEX blocks_transactions_count ON blocks(transactions_count);
CREATE INDEX blocks_reward ON blocks(reward);
CREATE INDEX blocks_amount ON blocks(amount);
CREATE INDEX blocks_fee ON blocks(fee);
CREATE INDEX blocks_validator_round ON blocks(validator_round);

CREATE INDEX receipts_block_height ON receipts(block_number);
CREATE INDEX receipts_contracts ON receipts(contract_address)
CREATE INDEX receipts_contracts ON receipts(contract_address)

Check warning on line 41 in packages/api-database/source/migrations/1697617471901-CreateIndexes.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-database/source/migrations/1697617471901-CreateIndexes.ts#L41

Added line #L41 was not covered by tests
WHERE contract_address IS NOT NULL;

CREATE INDEX wallets_balance ON wallets(balance);
Expand Down Expand Up @@ -82,7 +81,6 @@

DROP INDEX blocks_transactions_count;
DROP INDEX blocks_reward;
DROP INDEX blocks_amount;
DROP INDEX blocks_fee;
DROP INDEX blocks_validator_round;

Expand Down
6 changes: 0 additions & 6 deletions packages/api-database/source/models/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ export class Block {
})
public readonly gasUsed!: number;

@Column({
nullable: false,
type: "numeric",
})
public readonly amount!: string;

@Column({
nullable: false,
type: "numeric",
Expand Down
1 change: 0 additions & 1 deletion packages/api-development/source/resources/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export class BlockResource implements Contracts.Api.Resource {

return {
forged: {
amount: blockData.amount.toFixed(),
fee: blockData.fee.toFixed(),
reward: blockData.reward.toFixed(),
total: blockData.reward.plus(blockData.fee).toFixed(),
Expand Down
1 change: 0 additions & 1 deletion packages/api-http/source/resources/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export class BlockResource implements Contracts.Api.Resource {

public transform(resource: EnrichedBlock): object {
return {
amount: BigNumber.make(resource.amount),
confirmations: +resource.state.blockNumber
? Number(resource.state.blockNumber) - Number(resource.number)
: 0,
Expand Down
3 changes: 0 additions & 3 deletions packages/api-http/test/fixtures/blocks.response.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"confirmations": 0,
"amount": "12499999999999969",
"fee": "0",
"gasUsed": 0,
"reward": "0",
Expand All @@ -22,7 +21,6 @@
},
{
"confirmations": 0,
"amount": "0",
"fee": "0",
"gasUsed": 0,
"reward": "0",
Expand All @@ -43,7 +41,6 @@
},
{
"confirmations": 0,
"amount": "0",
"fee": "0",
"gasUsed": 0,
"reward": "0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[
{
"confirmations": 0,
"amount": "0",
"fee": "0",
"gasUsed": 0,
"reward": "0",
Expand All @@ -23,7 +22,6 @@
},
{
"confirmations": 0,
"amount": "12499999999999969",
"fee": "0",
"gasUsed": 0,
"reward": "0",
Expand Down
1 change: 0 additions & 1 deletion packages/api-sync/source/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ export class Restore {

for await (const { proof, block } of commits) {
blocks.push({
amount: block.header.amount.toFixed(),
commitRound: proof.round,
fee: block.header.fee.toFixed(),
gasUsed: block.header.gasUsed,
Expand Down
7 changes: 3 additions & 4 deletions packages/api-sync/source/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@
? {
// incrementally applied in UPSERT below
validatorForgedFees: header.fee.toFixed(),
validatorForgedRewards: header.amount.toFixed(),
validatorForgedTotal: header.fee.plus(header.amount).toFixed(),
validatorForgedRewards: header.reward.toFixed(),
validatorForgedTotal: header.fee.plus(header.reward).toFixed(),

Check warning on line 196 in packages/api-sync/source/service.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-sync/source/service.ts#L195-L196

Added lines #L195 - L196 were not covered by tests
validatorLastBlock: {
hash: header.hash,
number: header.number,
Expand Down Expand Up @@ -259,7 +259,6 @@

const deferredSync: DeferredSync = {
block: {
amount: header.amount.toFixed(),
commitRound: proof.round,
fee: header.fee.toFixed(),
gasUsed: header.gasUsed,
Expand Down Expand Up @@ -490,7 +489,7 @@
'validatorVotersCount',
COALESCE(EXCLUDED.attributes->'validatorVotersCount', "Wallet".attributes->'validatorVotersCount'),
'validatorFee',
COALESCE((EXCLUDED.attributes->>'validatorFee')::text, ("Wallet".attributes->>'validatorFee')::text),
COALESCE((EXCLUDED.attributes->>'validatorFee')::text, ("Wallet".attributes->>'validatorFee')::text),

Check warning on line 492 in packages/api-sync/source/service.ts

View check run for this annotation

Codecov / codecov/patch

packages/api-sync/source/service.ts#L492

Added line #L492 was not covered by tests
'validatorLastBlock',
COALESCE((EXCLUDED.attributes->>'validatorLastBlock')::jsonb, ("Wallet".attributes->>'validatorLastBlock')::jsonb),
'validatorForgedFees',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,7 @@ export class GenesisBlockGenerator extends Generator {
transactions: Contracts.Crypto.Transaction[],
options: Contracts.NetworkGenerator.InternalOptions,
): Promise<{ block: Contracts.Crypto.Block; transactions: Contracts.Crypto.TransactionData[] }> {
const totals: { amount: BigNumber; fee: BigNumber; gasUsed: number } = {
amount: BigNumber.ZERO,
const totals: { fee: BigNumber; gasUsed: number } = {
fee: BigNumber.ZERO,
gasUsed: 0,
};
Expand Down Expand Up @@ -292,7 +291,6 @@ export class GenesisBlockGenerator extends Generator {
value: transaction.data.value.toBigInt(),
});

totals.amount = totals.amount.plus(data.value);
totals.fee = totals.fee.plus(data.gasPrice);
totals.gasUsed += Number(receipt.gasUsed);

Expand Down Expand Up @@ -320,7 +318,6 @@ export class GenesisBlockGenerator extends Generator {
return {
block: await this.app.get<Contracts.Crypto.BlockFactory>(Identifiers.Cryptography.Block.Factory).make(
{
amount: options.snapshot ? BigNumber.make(options.premine) : totals.amount,
fee: totals.fee,
gasUsed: totals.gasUsed,
logsBloom: await this.evm.logsBloom(commitKey),
Expand Down
2 changes: 0 additions & 2 deletions packages/contracts/source/contracts/crypto/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export interface BlockData {
readonly logsBloom: string;
readonly transactionsCount: number;
readonly gasUsed: number;
readonly amount: BigNumber;
readonly fee: BigNumber;
readonly reward: BigNumber;
readonly payloadSize: number;
Expand All @@ -49,7 +48,6 @@ export interface BlockJson {
readonly logsBloom: string;
readonly transactionsCount: number;
readonly gasUsed: number;
readonly amount: string;
readonly fee: string;
readonly reward: string;
readonly payloadSize: number;
Expand Down
6 changes: 0 additions & 6 deletions packages/contracts/source/exceptions/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,6 @@ export class DuplicatedTransaction extends ValidatorException {
}
}

export class InvalidAmount extends ValidatorException {
public constructor(block: Block, actualAmount: string) {
super(`Block ${block.data.hash} has invalid amount. Expected ${block.data.amount}, but got ${actualAmount}.`);
}
}

export class ExceededGasLimit extends ValidatorException {
public constructor(block: Block, maxGasLimit: number) {
super(`Block ${block.data.hash} with gas used ${block.data.gasUsed} exceeds max gas limit of ${maxGasLimit}.`);
Expand Down
Loading
Loading