From e605a860501e1c3080f24fb54f5433fcabce9928 Mon Sep 17 00:00:00 2001 From: ptrus Date: Mon, 20 Jan 2025 12:37:58 +0100 Subject: [PATCH] wip --- analyzer/consensus/consensus.go | 9 ++ analyzer/consensus/data_fetch.go | 2 +- analyzer/queries/queries.go | 10 +- api/spec/v1.yaml | 44 ++++--- coreapi/v24.0/consensus/api/api.go | 4 + storage/client/client.go | 3 + storage/client/queries/queries.go | 5 +- storage/migrations/00_consensus.up.sql | 3 + .../12_consensus_tx_new_fields.up.sql | 8 ++ storage/oasis/nodeapi/api.go | 115 +++++++++--------- storage/oasis/nodeapi/cobalt/convert.go | 2 +- storage/oasis/nodeapi/cobalt/node.go | 2 +- storage/oasis/nodeapi/damask/convert.go | 5 +- storage/oasis/nodeapi/damask/node.go | 5 +- storage/oasis/nodeapi/eden/node.go | 5 +- storage/oasis/nodeapi/file/consensus.go | 2 +- storage/oasis/nodeapi/history/history.go | 2 +- 17 files changed, 137 insertions(+), 89 deletions(-) create mode 100644 storage/migrations/12_consensus_tx_new_fields.up.sql diff --git a/analyzer/consensus/consensus.go b/analyzer/consensus/consensus.go index 5b3abb4a5..dd5cbc27e 100644 --- a/analyzer/consensus/consensus.go +++ b/analyzer/consensus/consensus.go @@ -410,6 +410,12 @@ func (m *processor) queueBlockInserts(batch *storage.QueryBatch, data *consensus proposerAddr = common.Ptr(entity.String()) } } + + var gasUsed uint64 + for _, txr := range data.TransactionsWithResults { + gasUsed += txr.Result.GasUsed + } + batch.Queue( queries.ConsensusBlockUpsert, data.BlockHeader.Height, @@ -417,7 +423,9 @@ func (m *processor) queueBlockInserts(batch *storage.QueryBatch, data *consensus data.BlockHeader.Time.UTC(), len(data.TransactionsWithResults), data.GasLimit, + gasUsed, data.SizeLimit, + data.BlockHeader.Size, data.Epoch, data.BlockHeader.StateRoot.Namespace.String(), int64(data.BlockHeader.StateRoot.Version), @@ -548,6 +556,7 @@ func (m *processor) queueTransactionInserts(batch *storage.QueryBatch, data *con module, result.Error.Code, message, + result.GasUsed, ) // Bump the nonce. if m.mode != analyzer.FastSyncMode { // Skip during fast sync; nonce will be provided by the genesis. diff --git a/analyzer/consensus/data_fetch.go b/analyzer/consensus/data_fetch.go index ca014be3f..695903b92 100644 --- a/analyzer/consensus/data_fetch.go +++ b/analyzer/consensus/data_fetch.go @@ -10,8 +10,8 @@ import ( sdkConfig "github.com/oasisprotocol/oasis-sdk/client-sdk/go/config" beacon "github.com/oasisprotocol/nexus/coreapi/v22.2.11/beacon/api" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" roothash "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api" + consensus "github.com/oasisprotocol/nexus/coreapi/v24.0/consensus/api" "github.com/oasisprotocol/nexus/storage/oasis/nodeapi" ) diff --git a/analyzer/queries/queries.go b/analyzer/queries/queries.go index c999aec46..09d5a166e 100644 --- a/analyzer/queries/queries.go +++ b/analyzer/queries/queries.go @@ -167,8 +167,8 @@ var ( height = excluded.height` ConsensusBlockUpsert = ` - INSERT INTO chain.blocks (height, block_hash, time, num_txs, gas_limit, size_limit, epoch, namespace, version, state_root, proposer_entity_id) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) + INSERT INTO chain.blocks (height, block_hash, time, num_txs, gas_limit, gas_used, size_limit, size, epoch, namespace, version, state_root, proposer_entity_id) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13) ON CONFLICT (height) DO UPDATE SET block_hash = excluded.block_hash, @@ -179,7 +179,9 @@ var ( state_root = excluded.state_root, epoch = excluded.epoch, gas_limit = excluded.gas_limit, + gas_used = excluded.gas_used, size_limit = excluded.size_limit, + size = excluded.size, proposer_entity_id = excluded.proposer_entity_id` ConsensusBlockAddSigners = ` @@ -211,8 +213,8 @@ var ( end_height = GREATEST(old.end_height, excluded.end_height)` ConsensusTransactionInsert = ` - INSERT INTO chain.transactions (block, tx_hash, tx_index, nonce, fee_amount, max_gas, method, sender, body, module, code, message) - VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)` + INSERT INTO chain.transactions (block, tx_hash, tx_index, nonce, fee_amount, max_gas, method, sender, body, module, code, message, gas_used) + VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13)` ConsensusAccountUpsert = ` INSERT INTO chain.accounts diff --git a/api/spec/v1.yaml b/api/spec/v1.yaml index 09e8b4baa..5274007ec 100644 --- a/api/spec/v1.yaml +++ b/api/spec/v1.yaml @@ -1423,7 +1423,7 @@ components: Block: type: object - required: [height, hash, timestamp, num_transactions, gas_limit, epoch, state_root, proposer] # TODO: size, gas_used + required: [height, hash, timestamp, num_transactions, gas_limit, epoch, state_root, proposer] properties: height: type: integer @@ -1445,13 +1445,16 @@ components: description: Number of transactions in the block. example: 17 gas_limit: - allOf: [$ref: '#/components/schemas/TextBigInt'] + type: integer + format: uint64 description: | The gas limit for the block. A gas limit 0 means that the max block gas was unlimited. Blocks from Cobalt, Damask, and early Eden had no gas limit as their sizes were only restricted by byte size until an upgrade during Eden introduced a gas limit. + example: 30000 size_limit: - allOf: [$ref: '#/components/schemas/TextBigInt'] + type: integer + format: uint64 description: | The size limit for the block in bytes. epoch: @@ -1471,17 +1474,19 @@ components: items: allOf: [$ref: '#/components/schemas/EntityInfo'] description: A list of the entities that signed the block. - # TODO: Not available on backend - # size: - # type: integer - # format: int64 - # description: Size of the block, in bytes. TODO: Be more exact. Should this include results? By far the easiest is to give the total bytesize of txs here. - # example: 123456 - # gas_used: - # type: integer - # format: int64 - # description: Total gas used by the transactions in the block. - # example: 123456 + size: + type: integer + format: uint64 + description: | + The size of the block in bytes. + This field is missing for blocks pre Oasis-Core 24.3. + gas_used: + type: integer + format: int64 + description: | + Total gas used by the transactions in the block. + This field is missing for blocks pre Oasis-Core 24.3. + example: 123456 description: | A consensus block. @@ -1688,9 +1693,18 @@ components: to pay to execute it. example: 1000 gas_limit: - allOf: [$ref: '#/components/schemas/TextBigInt'] + type: integer + format: uint64 description: | The maximum gas that a transaction can use. + example: 30000 + gas_used: + type: integer + format: uint64 + description: | + The gas used by the transaction. + This field is missing for transactions pre Oasis-Core 24.3. + example: 30000 method: allOf: [$ref: '#/components/schemas/ConsensusTxMethod'] description: The method that was called. diff --git a/coreapi/v24.0/consensus/api/api.go b/coreapi/v24.0/consensus/api/api.go index c4eedeb92..249f9e8ac 100644 --- a/coreapi/v24.0/consensus/api/api.go +++ b/coreapi/v24.0/consensus/api/api.go @@ -79,6 +79,8 @@ type Block struct { Time time.Time `json:"time"` // StateRoot is the Merkle root of the consensus state tree. StateRoot mkvsNode.Root `json:"state_root"` + // Size is the size of the block in bytes. + Size uint64 `json:"size,omitempty"` // Added in 24.3. // Meta contains the consensus backend specific block metadata. Meta cbor.RawMessage `json:"meta"` } @@ -178,6 +180,8 @@ type Status struct { // nolint: maligned LatestEpoch beacon.EpochTime `json:"latest_epoch"` // LatestStateRoot is the Merkle root of the consensus state tree. LatestStateRoot mkvsNode.Root `json:"latest_state_root"` + // LatestBlockSize is the size (in bytes) of the latest block. + LatestBlockSize uint64 `json:"latest_block_size,omitempty"` // Added in 24.3. // GenesisHeight is the height of the genesis block. GenesisHeight int64 `json:"genesis_height"` diff --git a/storage/client/client.go b/storage/client/client.go index 7f5be3103..16d57021e 100644 --- a/storage/client/client.go +++ b/storage/client/client.go @@ -348,7 +348,9 @@ func (c *StorageClient) Blocks(ctx context.Context, r apiTypes.GetConsensusBlock &b.Timestamp, &b.NumTransactions, &b.GasLimit, + &b.GasUsed, &b.SizeLimit, + &b.Size, &b.Epoch, &b.StateRoot, &proposerRow, @@ -428,6 +430,7 @@ func (c *StorageClient) Transactions(ctx context.Context, p apiTypes.GetConsensu &t.Nonce, &t.Fee, &t.GasLimit, + &t.GasUsed, &t.Method, &t.Body, &code, diff --git a/storage/client/queries/queries.go b/storage/client/queries/queries.go index aefdf5c62..5ef17ecd8 100644 --- a/storage/client/queries/queries.go +++ b/storage/client/queries/queries.go @@ -30,7 +30,9 @@ const ( time, num_txs, gas_limit, + gas_used, size_limit, + size, epoch, state_root, ROW( @@ -76,12 +78,13 @@ const ( chain.transactions.nonce as nonce, chain.transactions.fee_amount as fee_amount, chain.transactions.max_gas as gas_limit, + chain.transactions.gas_used as gas_used, chain.transactions.method as method, chain.transactions.body as body, chain.transactions.code as code, chain.transactions.module as module, chain.transactions.message as message, - chain.blocks.time as time + chain.blocks.time as time, FROM chain.transactions JOIN chain.blocks ON chain.transactions.block = chain.blocks.height LEFT JOIN chain.accounts_related_transactions ON chain.transactions.block = chain.accounts_related_transactions.tx_block diff --git a/storage/migrations/00_consensus.up.sql b/storage/migrations/00_consensus.up.sql index 18bfc61c8..1b3799525 100644 --- a/storage/migrations/00_consensus.up.sql +++ b/storage/migrations/00_consensus.up.sql @@ -36,7 +36,9 @@ CREATE TABLE chain.blocks time TIMESTAMP WITH TIME ZONE NOT NULL, num_txs UINT31 NOT NULL, gas_limit UINT_NUMERIC NOT NULL DEFAULT 0, -- uint64 in go; because the value might conceivably be >2^63, we use UINT_NUMERIC over UINT63 here. + -- gas_used UINT_NUMERIC, -- Added in 12_consensus_tx_new_fields.up.sql size_limit UINT_NUMERIC NOT NULL DEFAULT 0, -- uint64 in go; because the value might conceivably be >2^63, we use UINT_NUMERIC over UINT63 here. + --size UINT_NUMERIC, -- Added in 12_consensus_tx_new_fields.up.sql epoch UINT63 NOT NULL DEFAULT 0, -- State Root Info @@ -62,6 +64,7 @@ CREATE TABLE chain.transactions nonce UINT63 NOT NULL, fee_amount UINT_NUMERIC, max_gas UINT_NUMERIC, -- uint64 in go; because the value might conceivably be >2^63, we use UINT_NUMERIC over UINT63 here. + --gas_used UINT_NUMERIC, -- Added in 12_consensus_tx_new_fields.up.sql method TEXT NOT NULL, sender oasis_addr NOT NULL, body JSONB, diff --git a/storage/migrations/12_consensus_tx_new_fields.up.sql b/storage/migrations/12_consensus_tx_new_fields.up.sql new file mode 100644 index 000000000..33d5db6f6 --- /dev/null +++ b/storage/migrations/12_consensus_tx_new_fields.up.sql @@ -0,0 +1,8 @@ +BEGIN; + +ALTER TABLE chain.transactions ADD COLUMN gas_used UINT_NUMERIC; +ALTER TABLE chain.blocks + ADD COLUMN size UINT_NUMERIC, + ADD COLUMN gas_used UINT_NUMERIC; + +COMMIT; diff --git a/storage/oasis/nodeapi/api.go b/storage/oasis/nodeapi/api.go index 49f72da77..344b10330 100644 --- a/storage/oasis/nodeapi/api.go +++ b/storage/oasis/nodeapi/api.go @@ -25,7 +25,6 @@ import ( beacon "github.com/oasisprotocol/nexus/coreapi/v22.2.11/beacon/api" node "github.com/oasisprotocol/nexus/coreapi/v22.2.11/common/node" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" consensusTransaction "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api/transaction" consensusResults "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api/transaction/results" registry "github.com/oasisprotocol/nexus/coreapi/v22.2.11/registry/api" @@ -33,6 +32,7 @@ import ( "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api/message" scheduler "github.com/oasisprotocol/nexus/coreapi/v22.2.11/scheduler/api" staking "github.com/oasisprotocol/nexus/coreapi/v22.2.11/staking/api" + consensus "github.com/oasisprotocol/nexus/coreapi/v24.0/consensus/api" governance "github.com/oasisprotocol/nexus/coreapi/v24.0/governance/api" "github.com/oasisprotocol/nexus/storage/oasis/connections" @@ -92,13 +92,14 @@ type ConsensusParameters struct { // A lightweight subset of `consensus.TransactionsWithResults`. type TransactionWithResults struct { - Transaction consensusTransaction.SignedTransaction - Result TxResult + Transaction consensusTransaction.SignedTransaction `json:"transaction"` + Result TxResult `json:"result"` } type TxResult struct { - Error TxError - Events []Event + Error TxError `json:"error"` + Events []Event `json:"events"` + GasUsed uint64 `json:"gas_used,omitempty"` // Added in 24.3. } // IsSuccess returns true if transaction execution was successful. @@ -116,8 +117,8 @@ type Address = staking.Address // Nexus actively inspects (as opposed to just logging them) to perform // dead reckoning or similar state updates. type Event struct { - Height int64 - TxHash hash.Hash + Height int64 `json:"height"` + TxHash hash.Hash `json:"tx_hash"` // The body of the Event struct as it was received from oasis-core. For most // event types, a summary of the event (containing only nexus-relevant fields) @@ -126,34 +127,34 @@ type Event struct { // field will be populated. // We convert to JSON and effectively erase the type here in order to decouple // oasis-core types (which vary between versions) from Nexus. - RawBody json.RawMessage + RawBody json.RawMessage `json:"raw_body"` // Called "Kind" in oasis-core but "Type" in Nexus APIs and DBs. - Type apiTypes.ConsensusEventType - - StakingTransfer *TransferEvent - StakingBurn *BurnEvent - StakingAddEscrow *AddEscrowEvent - StakingTakeEscrow *TakeEscrowEvent - StakingEscrowDebondingStart *DebondingStartEscrowEvent - StakingReclaimEscrow *ReclaimEscrowEvent - StakingDebondingStart *DebondingStartEscrowEvent // Available starting in Damask. - StakingAllowanceChange *AllowanceChangeEvent - - RegistryRuntimeStarted *RuntimeStartedEvent - RegistryRuntimeSuspended *RuntimeSuspendedEvent // Available starting with Eden. - RegistryEntity *EntityEvent - RegistryNode *NodeEvent - RegistryNodeUnfrozen *NodeUnfrozenEvent - - RoothashMisc *RoothashEvent - RoothashExecutorCommitted *ExecutorCommittedEvent - RoothashMessage *MessageEvent // Available only in Cobalt. - - GovernanceProposalSubmitted *ProposalSubmittedEvent - GovernanceProposalExecuted *ProposalExecutedEvent - GovernanceProposalFinalized *ProposalFinalizedEvent - GovernanceVote *VoteEvent + Type apiTypes.ConsensusEventType `json:"type"` + + StakingTransfer *TransferEvent `json:"staking_transfer,omitempty"` + StakingBurn *BurnEvent `json:"staking_burn,omitempty"` + StakingAddEscrow *AddEscrowEvent `json:"staking_add_escrow,omitempty"` + StakingTakeEscrow *TakeEscrowEvent `json:"staking_take_escrow,omitempty"` + StakingEscrowDebondingStart *DebondingStartEscrowEvent `json:"staking_escrow_debonding_start,omitempty"` + StakingReclaimEscrow *ReclaimEscrowEvent `json:"staking_reclaim_escrow,omitempty"` + StakingDebondingStart *DebondingStartEscrowEvent `json:"staking_debonding_start,omitempty"` // Available starting in Damask. + StakingAllowanceChange *AllowanceChangeEvent `json:"staking_allowance_change,omitempty"` + + RegistryRuntimeStarted *RuntimeStartedEvent `json:"registry_runtime_registered,omitempty"` + RegistryRuntimeSuspended *RuntimeSuspendedEvent `json:"registry_runtime_suspended,omitempty"` // Available starting with Eden. + RegistryEntity *EntityEvent `json:"registry_entity,omitempty"` + RegistryNode *NodeEvent `json:"registry_node,omitempty"` + RegistryNodeUnfrozen *NodeUnfrozenEvent `json:"registry_node_unfrozen,omitempty"` + + RoothashMisc *RoothashEvent `json:"roothash_misc,omitempty"` + RoothashExecutorCommitted *ExecutorCommittedEvent `json:"roothash_executor_committed,omitempty"` + RoothashMessage *MessageEvent `json:"roothash_message,omitempty"` // Available only in Cobalt. + + GovernanceProposalSubmitted *ProposalSubmittedEvent `json:"governance_proposal_submitted,omitempty"` + GovernanceProposalExecuted *ProposalExecutedEvent `json:"governance_proposal_executed,omitempty"` + GovernanceProposalFinalized *ProposalFinalizedEvent `json:"governance_proposal_finalized,omitempty"` + GovernanceVote *VoteEvent `json:"governance_vote,omitempty"` } // .................... Staking .................... @@ -175,35 +176,35 @@ type ( // This is a stripped-down version of an unfortunately named `registry.RuntimeEvent` (in Cobalt and Damask). // Post-Damask, this is replaced by registry.RuntimeStartedEvent. type RuntimeStartedEvent struct { - ID coreCommon.Namespace - EntityID signature.PublicKey // The Entity controlling the runtime. - Kind string // enum: "compute", "keymanager" - KeyManager *coreCommon.Namespace // Key manager runtime ID. - TEEHardware string // enum: "invalid" (= no TEE), "intel-sgx" + ID coreCommon.Namespace `json:"id"` + EntityID signature.PublicKey `json:"entity_id"` // The Entity controlling the runtime. + Kind string `json:"kind"` // enum: "compute", "keymanager" + KeyManager *coreCommon.Namespace `json:"key_manager,omitempty"` // Key manager runtime ID. + TEEHardware string `json:"tee_hardware"` // enum: "invalid" (= no TEE), "intel-sgx" } type RuntimeSuspendedEvent struct { - RuntimeID coreCommon.Namespace + RuntimeID coreCommon.Namespace `json:"runtime_id"` } type ( Node node.Node NodeUnfrozenEvent registry.NodeUnfrozenEvent EntityEvent registry.EntityEvent NodeEvent struct { - NodeID signature.PublicKey - EntityID signature.PublicKey - Expiration uint64 // Epoch in which the node expires. - RuntimeIDs []coreCommon.Namespace - VRFPubKey *signature.PublicKey - TLSAddresses []string // TCP addresses of the node's TLS-enabled gRPC endpoint. - TLSPubKey signature.PublicKey - TLSNextPubKey signature.PublicKey - P2PID signature.PublicKey - P2PAddresses []string // TCP addresses of the node's P2P endpoint. - ConsensusID signature.PublicKey - ConsensusAddresses []string // TCP addresses of the node's tendermint endpoint. - Roles []string // enum: "compute", "key-manager", "validator", "consensus-rpc", "storage-rpc" - SoftwareVersion string - IsRegistration bool + NodeID signature.PublicKey `json:"node_id"` + EntityID signature.PublicKey `json:"entity_id"` + Expiration uint64 `json:"expiration"` // Epoch in which the node expires. + RuntimeIDs []coreCommon.Namespace `json:"runtime_ids"` + VRFPubKey *signature.PublicKey `json:"vrf_pub_key,omitempty"` + TLSAddresses []string `json:"tls_addresses"` // TCP addresses of the node's TLS-enabled gRPC endpoint. + TLSPubKey signature.PublicKey `json:"tls_pub_key"` + TLSNextPubKey signature.PublicKey `json:"tls_next_pub_key,omitempty"` + P2PID signature.PublicKey `json:"p2p_id"` + P2PAddresses []string `json:"p2p_addresses"` // TCP addresses of the node's P2P endpoint. + ConsensusID signature.PublicKey `json:"consensus_id"` + ConsensusAddresses []string `json:"consensus_addresses"` // TCP addresses of the node's tendermint endpoint. + Roles []string `json:"roles"` // enum: "compute", "key-manager", "validator", "consensus-rpc", "storage-rpc" + SoftwareVersion string `json:"software_version"` + IsRegistration bool `json:"is_registration"` } ) @@ -246,9 +247,9 @@ type ( ProposalExecutedEvent governance.ProposalExecutedEvent ProposalFinalizedEvent governance.ProposalFinalizedEvent VoteEvent struct { - ID uint64 - Submitter staking.Address - Vote string // enum: "yes", "no", "abstain" + ID uint64 `json:"id"` + Submitter staking.Address `json:"submitter"` + Vote string `json:"vote"` // enum: "yes", "no", "abstain" } ) diff --git a/storage/oasis/nodeapi/cobalt/convert.go b/storage/oasis/nodeapi/cobalt/convert.go index a6a12dd10..3924e5987 100644 --- a/storage/oasis/nodeapi/cobalt/convert.go +++ b/storage/oasis/nodeapi/cobalt/convert.go @@ -11,11 +11,11 @@ import ( // nexus-internal data types. coreCommon "github.com/oasisprotocol/oasis-core/go/common" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" registry "github.com/oasisprotocol/nexus/coreapi/v22.2.11/registry/api" "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api/message" scheduler "github.com/oasisprotocol/nexus/coreapi/v22.2.11/scheduler/api" staking "github.com/oasisprotocol/nexus/coreapi/v22.2.11/staking/api" + consensus "github.com/oasisprotocol/nexus/coreapi/v24.0/consensus/api" governance "github.com/oasisprotocol/nexus/coreapi/v24.0/governance/api" upgrade "github.com/oasisprotocol/nexus/coreapi/v24.0/upgrade/api" diff --git a/storage/oasis/nodeapi/cobalt/node.go b/storage/oasis/nodeapi/cobalt/node.go index 2f3519df0..4b30e8a91 100644 --- a/storage/oasis/nodeapi/cobalt/node.go +++ b/storage/oasis/nodeapi/cobalt/node.go @@ -11,11 +11,11 @@ import ( cmdCommon "github.com/oasisprotocol/nexus/cmd/common" beacon "github.com/oasisprotocol/nexus/coreapi/v22.2.11/beacon/api" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" consensusTx "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api/transaction" governance "github.com/oasisprotocol/nexus/coreapi/v22.2.11/governance/api" roothash "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api" scheduler "github.com/oasisprotocol/nexus/coreapi/v22.2.11/scheduler/api" + consensus "github.com/oasisprotocol/nexus/coreapi/v24.0/consensus/api" "github.com/oasisprotocol/nexus/storage/oasis/connections" "github.com/oasisprotocol/nexus/storage/oasis/nodeapi" diff --git a/storage/oasis/nodeapi/damask/convert.go b/storage/oasis/nodeapi/damask/convert.go index 93c24e7e3..f7e912d2e 100644 --- a/storage/oasis/nodeapi/damask/convert.go +++ b/storage/oasis/nodeapi/damask/convert.go @@ -302,8 +302,9 @@ func convertTxResult(r txResultsDamask.Result) nodeapi.TxResult { } return nodeapi.TxResult{ - Error: nodeapi.TxError(r.Error), - Events: events, + Error: nodeapi.TxError(r.Error), + Events: events, + GasUsed: 0, // Missing in Damask. } } diff --git a/storage/oasis/nodeapi/damask/node.go b/storage/oasis/nodeapi/damask/node.go index 9304f2390..aa667293d 100644 --- a/storage/oasis/nodeapi/damask/node.go +++ b/storage/oasis/nodeapi/damask/node.go @@ -11,7 +11,7 @@ import ( // nexus-internal data types. beacon "github.com/oasisprotocol/nexus/coreapi/v22.2.11/beacon/api" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" + consensusDamask "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" consensusTx "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api/transaction" genesis "github.com/oasisprotocol/nexus/coreapi/v22.2.11/genesis/api" governance "github.com/oasisprotocol/nexus/coreapi/v22.2.11/governance/api" @@ -19,6 +19,7 @@ import ( roothash "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api" scheduler "github.com/oasisprotocol/nexus/coreapi/v22.2.11/scheduler/api" staking "github.com/oasisprotocol/nexus/coreapi/v22.2.11/staking/api" + consensus "github.com/oasisprotocol/nexus/coreapi/v24.0/consensus/api" "github.com/oasisprotocol/nexus/storage/oasis/connections" "github.com/oasisprotocol/nexus/storage/oasis/nodeapi" @@ -82,7 +83,7 @@ func (c *ConsensusApiLite) GetBlock(ctx context.Context, height int64) (*consens } func (c *ConsensusApiLite) GetTransactionsWithResults(ctx context.Context, height int64) ([]nodeapi.TransactionWithResults, error) { - var rsp consensus.TransactionsWithResults + var rsp consensusDamask.TransactionsWithResults if err := c.grpcConn.Invoke(ctx, "/oasis-core.Consensus/GetTransactionsWithResults", height, &rsp); err != nil { return nil, fmt.Errorf("GetTransactionsWithResults(%d): %w", height, err) } diff --git a/storage/oasis/nodeapi/eden/node.go b/storage/oasis/nodeapi/eden/node.go index 28c59130f..17b79ef2d 100644 --- a/storage/oasis/nodeapi/eden/node.go +++ b/storage/oasis/nodeapi/eden/node.go @@ -11,7 +11,6 @@ import ( // nexus-internal data types. beacon "github.com/oasisprotocol/nexus/coreapi/v22.2.11/beacon/api" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" consensusTx "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api/transaction" roothash "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api" @@ -78,12 +77,12 @@ func (c *ConsensusApiLite) GetConsensusParameters(ctx context.Context, height in }, nil } -func (c *ConsensusApiLite) GetBlock(ctx context.Context, height int64) (*consensus.Block, error) { +func (c *ConsensusApiLite) GetBlock(ctx context.Context, height int64) (*consensusEden.Block, error) { var rsp consensusEden.Block if err := c.grpcConn.Invoke(ctx, "/oasis-core.Consensus/GetBlock", height, &rsp); err != nil { return nil, fmt.Errorf("GetBlock(%d): %w", height, err) } - return (*consensus.Block)(&rsp), nil + return &rsp, nil } func (c *ConsensusApiLite) GetTransactionsWithResults(ctx context.Context, height int64) ([]nodeapi.TransactionWithResults, error) { diff --git a/storage/oasis/nodeapi/file/consensus.go b/storage/oasis/nodeapi/file/consensus.go index 82967e046..a365948a7 100644 --- a/storage/oasis/nodeapi/file/consensus.go +++ b/storage/oasis/nodeapi/file/consensus.go @@ -8,8 +8,8 @@ import ( cmdCommon "github.com/oasisprotocol/nexus/cmd/common" beacon "github.com/oasisprotocol/nexus/coreapi/v22.2.11/beacon/api" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" roothash "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api" + consensus "github.com/oasisprotocol/nexus/coreapi/v24.0/consensus/api" "github.com/oasisprotocol/nexus/cache/kvstore" "github.com/oasisprotocol/nexus/common" diff --git a/storage/oasis/nodeapi/history/history.go b/storage/oasis/nodeapi/history/history.go index 4f43292ed..cc03ac5f5 100644 --- a/storage/oasis/nodeapi/history/history.go +++ b/storage/oasis/nodeapi/history/history.go @@ -7,8 +7,8 @@ import ( "github.com/oasisprotocol/oasis-core/go/common" beacon "github.com/oasisprotocol/nexus/coreapi/v22.2.11/beacon/api" - consensus "github.com/oasisprotocol/nexus/coreapi/v22.2.11/consensus/api" roothash "github.com/oasisprotocol/nexus/coreapi/v22.2.11/roothash/api" + consensus "github.com/oasisprotocol/nexus/coreapi/v24.0/consensus/api" "github.com/oasisprotocol/nexus/config" "github.com/oasisprotocol/nexus/storage/oasis/connections"