Skip to content

Commit bbacb8a

Browse files
refactor(crypto-block): remove amount (#987)
* Remove amount from serializer * Remove amount verifier * Remove amount from database * Remove from generator * Remove from test framework * Update network * Fix crypto-block tests * Fix test-framework * Remove amount * style: resolve style guide violations * Fix crypto-message tests * Generate test networks * Regenerate test networks * style: resolve style guide violations * Remove indexes * Fix integration tests
1 parent 38bd66d commit bbacb8a

56 files changed

Lines changed: 6540 additions & 6649 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,11 @@ export class CreateIndexes1697617471901 implements MigrationInterface {
3434
3535
CREATE INDEX blocks_transactions_count ON blocks(transactions_count);
3636
CREATE INDEX blocks_reward ON blocks(reward);
37-
CREATE INDEX blocks_amount ON blocks(amount);
3837
CREATE INDEX blocks_fee ON blocks(fee);
3938
CREATE INDEX blocks_validator_round ON blocks(validator_round);
4039
4140
CREATE INDEX receipts_block_height ON receipts(block_number);
42-
CREATE INDEX receipts_contracts ON receipts(contract_address)
41+
CREATE INDEX receipts_contracts ON receipts(contract_address)
4342
WHERE contract_address IS NOT NULL;
4443
4544
CREATE INDEX wallets_balance ON wallets(balance);
@@ -82,7 +81,6 @@ export class CreateIndexes1697617471901 implements MigrationInterface {
8281
8382
DROP INDEX blocks_transactions_count;
8483
DROP INDEX blocks_reward;
85-
DROP INDEX blocks_amount;
8684
DROP INDEX blocks_fee;
8785
DROP INDEX blocks_validator_round;
8886

packages/api-database/source/models/block.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@ export class Block {
5252
})
5353
public readonly gasUsed!: number;
5454

55-
@Column({
56-
nullable: false,
57-
type: "numeric",
58-
})
59-
public readonly amount!: string;
60-
6155
@Column({
6256
nullable: false,
6357
type: "numeric",

packages/api-development/source/resources/block.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class BlockResource implements Contracts.Api.Resource {
1212

1313
return {
1414
forged: {
15-
amount: blockData.amount.toFixed(),
1615
fee: blockData.fee.toFixed(),
1716
reward: blockData.reward.toFixed(),
1817
total: blockData.reward.plus(blockData.fee).toFixed(),

packages/api-http/source/resources/block.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ export class BlockResource implements Contracts.Api.Resource {
1616

1717
public transform(resource: EnrichedBlock): object {
1818
return {
19-
amount: BigNumber.make(resource.amount),
2019
confirmations: +resource.state.blockNumber
2120
? Number(resource.state.blockNumber) - Number(resource.number)
2221
: 0,

packages/api-http/test/fixtures/blocks.response.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
{
33
"confirmations": 0,
4-
"amount": "12499999999999969",
54
"fee": "0",
65
"gasUsed": 0,
76
"reward": "0",
@@ -22,7 +21,6 @@
2221
},
2322
{
2423
"confirmations": 0,
25-
"amount": "0",
2624
"fee": "0",
2725
"gasUsed": 0,
2826
"reward": "0",
@@ -43,7 +41,6 @@
4341
},
4442
{
4543
"confirmations": 0,
46-
"amount": "0",
4744
"fee": "0",
4845
"gasUsed": 0,
4946
"reward": "0",

packages/api-http/test/fixtures/validator_blocks.response.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[
22
{
33
"confirmations": 0,
4-
"amount": "0",
54
"fee": "0",
65
"gasUsed": 0,
76
"reward": "0",
@@ -23,7 +22,6 @@
2322
},
2423
{
2524
"confirmations": 0,
26-
"amount": "12499999999999969",
2725
"fee": "0",
2826
"gasUsed": 0,
2927
"reward": "0",

packages/api-sync/source/restore.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ export class Restore {
236236

237237
for await (const { proof, block } of commits) {
238238
blocks.push({
239-
amount: block.header.amount.toFixed(),
240239
commitRound: proof.round,
241240
fee: block.header.fee.toFixed(),
242241
gasUsed: block.header.gasUsed,

packages/api-sync/source/service.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,8 @@ export class Sync implements Contracts.ApiSync.Service {
192192
? {
193193
// incrementally applied in UPSERT below
194194
validatorForgedFees: header.fee.toFixed(),
195-
validatorForgedRewards: header.amount.toFixed(),
196-
validatorForgedTotal: header.fee.plus(header.amount).toFixed(),
195+
validatorForgedRewards: header.reward.toFixed(),
196+
validatorForgedTotal: header.fee.plus(header.reward).toFixed(),
197197
validatorLastBlock: {
198198
hash: header.hash,
199199
number: header.number,
@@ -259,7 +259,6 @@ export class Sync implements Contracts.ApiSync.Service {
259259

260260
const deferredSync: DeferredSync = {
261261
block: {
262-
amount: header.amount.toFixed(),
263262
commitRound: proof.round,
264263
fee: header.fee.toFixed(),
265264
gasUsed: header.gasUsed,
@@ -490,7 +489,7 @@ export class Sync implements Contracts.ApiSync.Service {
490489
'validatorVotersCount',
491490
COALESCE(EXCLUDED.attributes->'validatorVotersCount', "Wallet".attributes->'validatorVotersCount'),
492491
'validatorFee',
493-
COALESCE((EXCLUDED.attributes->>'validatorFee')::text, ("Wallet".attributes->>'validatorFee')::text),
492+
COALESCE((EXCLUDED.attributes->>'validatorFee')::text, ("Wallet".attributes->>'validatorFee')::text),
494493
'validatorLastBlock',
495494
COALESCE((EXCLUDED.attributes->>'validatorLastBlock')::jsonb, ("Wallet".attributes->>'validatorLastBlock')::jsonb),
496495
'validatorForgedFees',

packages/configuration-generator/source/generators/genesis-block.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ export class GenesisBlockGenerator extends Generator {
241241
transactions: Contracts.Crypto.Transaction[],
242242
options: Contracts.NetworkGenerator.InternalOptions,
243243
): Promise<{ block: Contracts.Crypto.Block; transactions: Contracts.Crypto.TransactionData[] }> {
244-
const totals: { amount: BigNumber; fee: BigNumber; gasUsed: number } = {
245-
amount: BigNumber.ZERO,
244+
const totals: { fee: BigNumber; gasUsed: number } = {
246245
fee: BigNumber.ZERO,
247246
gasUsed: 0,
248247
};
@@ -292,7 +291,6 @@ export class GenesisBlockGenerator extends Generator {
292291
value: transaction.data.value.toBigInt(),
293292
});
294293

295-
totals.amount = totals.amount.plus(data.value);
296294
totals.fee = totals.fee.plus(data.gasPrice);
297295
totals.gasUsed += Number(receipt.gasUsed);
298296

@@ -320,7 +318,6 @@ export class GenesisBlockGenerator extends Generator {
320318
return {
321319
block: await this.app.get<Contracts.Crypto.BlockFactory>(Identifiers.Cryptography.Block.Factory).make(
322320
{
323-
amount: options.snapshot ? BigNumber.make(options.premine) : totals.amount,
324321
fee: totals.fee,
325322
gasUsed: totals.gasUsed,
326323
logsBloom: await this.evm.logsBloom(commitKey),

packages/contracts/source/contracts/crypto/block.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export interface BlockData {
2525
readonly logsBloom: string;
2626
readonly transactionsCount: number;
2727
readonly gasUsed: number;
28-
readonly amount: BigNumber;
2928
readonly fee: BigNumber;
3029
readonly reward: BigNumber;
3130
readonly payloadSize: number;
@@ -49,7 +48,6 @@ export interface BlockJson {
4948
readonly logsBloom: string;
5049
readonly transactionsCount: number;
5150
readonly gasUsed: number;
52-
readonly amount: string;
5351
readonly fee: string;
5452
readonly reward: string;
5553
readonly payloadSize: number;

0 commit comments

Comments
 (0)