diff --git a/internal/transform/contract_code.go b/internal/transform/contract_code.go index bea834a3..b026d11d 100644 --- a/internal/transform/contract_code.go +++ b/internal/transform/contract_code.go @@ -38,6 +38,31 @@ func TransformContractCode(ledgerChange ingest.Change, header xdr.LedgerHeaderHi ledgerSequence := header.Header.LedgerSeq + var outputNInstructions uint32 + var outputNFunctions uint32 + var outputNGlobals uint32 + var outputNTableEntries uint32 + var outputNTypes uint32 + var outputNDataSegments uint32 + var outputNElemSegments uint32 + var outputNImports uint32 + var outputNExports uint32 + var outputNDataSegmentBytes uint32 + + extV1, ok := contractCode.Ext.GetV1() + if ok { + outputNInstructions = uint32(extV1.CostInputs.NInstructions) + outputNFunctions = uint32(extV1.CostInputs.NFunctions) + outputNGlobals = uint32(extV1.CostInputs.NGlobals) + outputNTableEntries = uint32(extV1.CostInputs.NTableEntries) + outputNTypes = uint32(extV1.CostInputs.NTypes) + outputNDataSegments = uint32(extV1.CostInputs.NDataSegments) + outputNElemSegments = uint32(extV1.CostInputs.NElemSegments) + outputNImports = uint32(extV1.CostInputs.NImports) + outputNExports = uint32(extV1.CostInputs.NExports) + outputNDataSegmentBytes = uint32(extV1.CostInputs.NDataSegmentBytes) + } + transformedCode := ContractCodeOutput{ ContractCodeHash: contractCodeHash, ContractCodeExtV: int32(contractCodeExtV), @@ -47,6 +72,16 @@ func TransformContractCode(ledgerChange ingest.Change, header xdr.LedgerHeaderHi ClosedAt: closedAt, LedgerSequence: uint32(ledgerSequence), LedgerKeyHash: ledgerKeyHash, + NInstructions: outputNInstructions, + NFunctions: outputNFunctions, + NGlobals: outputNGlobals, + NTableEntries: outputNTableEntries, + NTypes: outputNTypes, + NDataSegments: outputNDataSegments, + NElemSegments: outputNElemSegments, + NImports: outputNImports, + NExports: outputNExports, + NDataSegmentBytes: outputNDataSegmentBytes, } return transformedCode, nil } diff --git a/internal/transform/contract_code_test.go b/internal/transform/contract_code_test.go index cc710081..c15467a6 100644 --- a/internal/transform/contract_code_test.go +++ b/internal/transform/contract_code_test.go @@ -69,6 +69,20 @@ func makeContractCodeTestInput() []ingest.Change { Hash: hash, Ext: xdr.ContractCodeEntryExt{ V: 1, + V1: &xdr.ContractCodeEntryV1{ + CostInputs: xdr.ContractCodeCostInputs{ + NInstructions: 1, + NFunctions: 2, + NGlobals: 3, + NTableEntries: 4, + NTypes: 5, + NDataSegments: 6, + NElemSegments: 7, + NImports: 8, + NExports: 9, + NDataSegmentBytes: 10, + }, + }, }, }, }, @@ -94,6 +108,16 @@ func makeContractCodeTestOutput() []ContractCodeOutput { LedgerSequence: 10, ClosedAt: time.Date(1970, time.January, 1, 0, 16, 40, 0, time.UTC), LedgerKeyHash: "dfed061dbe464e0ff320744fcd604ac08b39daa74fa24110936654cbcb915ccc", + NInstructions: 1, + NFunctions: 2, + NGlobals: 3, + NTableEntries: 4, + NTypes: 5, + NDataSegments: 6, + NElemSegments: 7, + NImports: 8, + NExports: 9, + NDataSegmentBytes: 10, }, } } diff --git a/internal/transform/schema.go b/internal/transform/schema.go index 5f78dba3..59fec01a 100644 --- a/internal/transform/schema.go +++ b/internal/transform/schema.go @@ -522,6 +522,16 @@ type ContractCodeOutput struct { LedgerSequence uint32 `json:"ledger_sequence"` LedgerKeyHash string `json:"ledger_key_hash"` //ContractCodeCode string `json:"contract_code"` + NInstructions uint32 `json:"n_instructions"` + NFunctions uint32 `json:"n_functions"` + NGlobals uint32 `json:"n_globals"` + NTableEntries uint32 `json:"n_table_entries"` + NTypes uint32 `json:"n_types"` + NDataSegments uint32 `json:"n_data_segments"` + NElemSegments uint32 `json:"n_elem_segments"` + NImports uint32 `json:"n_imports"` + NExports uint32 `json:"n_exports"` + NDataSegmentBytes uint32 `json:"n_data_segment_bytes"` } // ConfigSettingOutput is a representation of soroban config settings that aligns with the Bigquery table config_settings