From 3742778b5779326526033c0ddf7f0f01b9ad1fbd Mon Sep 17 00:00:00 2001 From: UlyanaAndrukhiv Date: Tue, 14 Jan 2025 16:24:17 +0200 Subject: [PATCH 1/3] Updated REST API Block model, updated flow version --- engine/access/rest/common/models/model_block.go | 2 +- go.mod | 3 +++ go.sum | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/engine/access/rest/common/models/model_block.go b/engine/access/rest/common/models/model_block.go index ded5008bcdc..5c1950b5861 100644 --- a/engine/access/rest/common/models/model_block.go +++ b/engine/access/rest/common/models/model_block.go @@ -12,7 +12,7 @@ type Block struct { Header *BlockHeader `json:"header"` Payload *BlockPayload `json:"payload,omitempty"` ExecutionResult *ExecutionResult `json:"execution_result,omitempty"` - Expandable *BlockExpandable `json:"_expandable"` + Expandable *BlockExpandable `json:"_expandable,omitempty"` Links *Links `json:"_links,omitempty"` BlockStatus string `json:"block_status"` } diff --git a/go.mod b/go.mod index eacd5e0ded0..cfb1470cbdb 100644 --- a/go.mod +++ b/go.mod @@ -324,3 +324,6 @@ require ( // Using custom fork until https://github.com/onflow/flow-go/issues/5338 is resolved replace github.com/ipfs/boxo => github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 + +// TODO: remove after PR on onflow/flow https://github.com/onflow/flow/pull/1539 merged and flow version bumped +replace github.com/onflow/flow => github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd diff --git a/go.sum b/go.sum index 15ec48eea52..4f798de5eb1 100644 --- a/go.sum +++ b/go.sum @@ -91,6 +91,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd h1:M01VqGZiWoPVl0lHkQR6XHJsINWbtp03OsPGzJz0ZrY= +github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd/go.mod h1:bIL/+5+AGyJnFfLGejMkZRGJiXopqdkMvkJNCjrpIa4= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= @@ -917,8 +919,6 @@ github.com/onflow/cadence v1.2.2 h1:LwigF/2lPiXlwX5rFn71KeMpmW5Iu/f/JtsPLLULBCc= github.com/onflow/cadence v1.2.2/go.mod h1:PYX1xLejqswtDsQzN93x/VpfSKNyjUk6hrkc/mpv7xs= github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= -github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= -github.com/onflow/flow v0.3.4/go.mod h1:lzyAYmbu1HfkZ9cfnL5/sjrrsnJiUU8fRL26CqLP7+c= github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ= github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 h1:u2DAG8pk0xFH7TwS70t1gSZ/FtIIZWMSNyiu4SeXBYg= From 28e9141a7aa0589b7c96533df13ebcd0a0b66e02 Mon Sep 17 00:00:00 2001 From: Andrii Slisarchuk Date: Thu, 23 Jan 2025 14:55:54 +0200 Subject: [PATCH 2/3] Added block status enum --- engine/access/rest/common/models/block.go | 19 ++++++++++++++++++- engine/access/rest/common/models/enums.go | 6 ++++++ .../access/rest/common/models/model_block.go | 2 +- .../rest/common/models/model_block_status.go | 19 +++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- 6 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 engine/access/rest/common/models/model_block_status.go diff --git a/engine/access/rest/common/models/block.go b/engine/access/rest/common/models/block.go index b94412929fa..6716c2c3be4 100644 --- a/engine/access/rest/common/models/block.go +++ b/engine/access/rest/common/models/block.go @@ -63,10 +63,27 @@ func (b *Block) Build( } b.Links = self - b.BlockStatus = blockStatus.String() + + var status BlockStatus + status.Build(blockStatus) + b.BlockStatus = &status + return nil } +func (b *BlockStatus) Build(status flow.BlockStatus) { + switch status { + case flow.BlockStatusUnknown: + *b = BLOCK_UNKNOWN + case flow.BlockStatusFinalized: + *b = BLOCK_FINALIZED + case flow.BlockStatusSealed: + *b = BLOCK_SEALED + default: + *b = "" + } +} + func (b *BlockPayload) Build(payload *flow.Payload) error { var blockSeal BlockSeals err := blockSeal.Build(payload.Seals) diff --git a/engine/access/rest/common/models/enums.go b/engine/access/rest/common/models/enums.go index 6d9b0d33b10..375aefdc6b1 100644 --- a/engine/access/rest/common/models/enums.go +++ b/engine/access/rest/common/models/enums.go @@ -15,3 +15,9 @@ const ( SUCCESS_RESULT = SUCCESS_TransactionExecution FAILURE_RESULT = FAILURE_TransactionExecution ) + +const ( + BLOCK_UNKNOWN = UNKNOWN_BlockStatus + BLOCK_FINALIZED = FINALIZED_BlockStatus + BLOCK_SEALED = SEALED_BlockStatus +) diff --git a/engine/access/rest/common/models/model_block.go b/engine/access/rest/common/models/model_block.go index 5c1950b5861..f30836ea1e4 100644 --- a/engine/access/rest/common/models/model_block.go +++ b/engine/access/rest/common/models/model_block.go @@ -14,5 +14,5 @@ type Block struct { ExecutionResult *ExecutionResult `json:"execution_result,omitempty"` Expandable *BlockExpandable `json:"_expandable,omitempty"` Links *Links `json:"_links,omitempty"` - BlockStatus string `json:"block_status"` + BlockStatus *BlockStatus `json:"block_status"` } diff --git a/engine/access/rest/common/models/model_block_status.go b/engine/access/rest/common/models/model_block_status.go new file mode 100644 index 00000000000..66e04825a42 --- /dev/null +++ b/engine/access/rest/common/models/model_block_status.go @@ -0,0 +1,19 @@ +/* + * Access API + * + * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) + * + * API version: 1.0.0 + * Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) + */ +package models + +// BlockStatus : This value indicates the status of a block. +type BlockStatus string + +// List of BlockStatus +const ( + UNKNOWN_BlockStatus BlockStatus = "BLOCK_UNKNOWN" + FINALIZED_BlockStatus BlockStatus = "BLOCK_FINALIZED" + SEALED_BlockStatus BlockStatus = "BLOCK_SEALED" +) diff --git a/go.mod b/go.mod index 14105c6a569..33601f21f87 100644 --- a/go.mod +++ b/go.mod @@ -325,4 +325,4 @@ require ( replace github.com/ipfs/boxo => github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 // TODO: remove after PR on onflow/flow https://github.com/onflow/flow/pull/1539 merged and flow version bumped -replace github.com/onflow/flow => github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd +replace github.com/onflow/flow => github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e diff --git a/go.sum b/go.sum index b478ccab479..a094ffceae9 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,8 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd h1:M01VqGZiWoPVl0lHkQR6XHJsINWbtp03OsPGzJz0ZrY= -github.com/The-K-R-O-K/flow v0.0.0-20250114135520-4c3fcf5ad9dd/go.mod h1:bIL/+5+AGyJnFfLGejMkZRGJiXopqdkMvkJNCjrpIa4= +github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e h1:6dvEjGvcHRHDYSZjCdaJtBAk3CjR+AhXc9EOe+3CtyY= +github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e/go.mod h1:bIL/+5+AGyJnFfLGejMkZRGJiXopqdkMvkJNCjrpIa4= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= From 01984e3563a339c9636ae3380b15557e37b76be4 Mon Sep 17 00:00:00 2001 From: Andrii Slisarchuk Date: Mon, 3 Feb 2025 12:19:50 +0200 Subject: [PATCH 3/3] chaged protobuf version --- go.mod | 5 +---- go.sum | 8 ++++---- insecure/go.mod | 2 +- insecure/go.sum | 4 ++-- integration/go.mod | 2 +- integration/go.sum | 4 ++-- 6 files changed, 11 insertions(+), 14 deletions(-) diff --git a/go.mod b/go.mod index 33601f21f87..4250121afdb 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 github.com/onflow/flow-go-sdk v1.3.0 - github.com/onflow/flow/protobuf/go/flow v0.4.7 + github.com/onflow/flow/protobuf/go/flow v0.4.9 github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 github.com/pierrec/lz4 v2.6.1+incompatible github.com/pkg/errors v0.9.1 @@ -323,6 +323,3 @@ require ( // Using custom fork until https://github.com/onflow/flow-go/issues/5338 is resolved replace github.com/ipfs/boxo => github.com/onflow/boxo v0.0.0-20240201202436-f2477b92f483 - -// TODO: remove after PR on onflow/flow https://github.com/onflow/flow/pull/1539 merged and flow version bumped -replace github.com/onflow/flow => github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e diff --git a/go.sum b/go.sum index a094ffceae9..f44f59cc497 100644 --- a/go.sum +++ b/go.sum @@ -89,8 +89,6 @@ github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWX github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI= github.com/StackExchange/wmi v1.2.1 h1:VIkavFPXSjcnS+O8yTq7NI32k0R5Aj+v39y29VYDOSA= github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= -github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e h1:6dvEjGvcHRHDYSZjCdaJtBAk3CjR+AhXc9EOe+3CtyY= -github.com/The-K-R-O-K/flow v0.0.0-20250123124738-e797132bf24e/go.mod h1:bIL/+5+AGyJnFfLGejMkZRGJiXopqdkMvkJNCjrpIa4= github.com/VictoriaMetrics/fastcache v1.12.2 h1:N0y9ASrJ0F6h0QaC3o6uJb3NIZ9VKLjCM7NQbSmF7WI= github.com/VictoriaMetrics/fastcache v1.12.2/go.mod h1:AmC+Nzz1+3G2eCPapF6UcsnkThDcMsQicp4xDukwJYI= github.com/VividCortex/gohistogram v1.0.0/go.mod h1:Pf5mBqqDxYaXu3hDrrU+w6nw50o/4+TcAqDqk/vUH7g= @@ -912,6 +910,8 @@ github.com/onflow/cadence v1.3.0 h1:COTlTqUACtTvOeFe7+jP9UDVEU3M3OZzrbzzsEbyqCk= github.com/onflow/cadence v1.3.0/go.mod h1:638c9Zy25EwflSEE7tBFAVM9N6uwcWt77sgKpyYfSTc= github.com/onflow/crypto v0.25.2 h1:GjHunqVt+vPcdqhxxhAXiMIF3YiLX7gTuTR5O+VG2ns= github.com/onflow/crypto v0.25.2/go.mod h1:fY7eLqUdMKV8EGOw301unP8h7PvLVy8/6gVR++/g0BY= +github.com/onflow/flow v0.3.4 h1:FXUWVdYB90f/rjNcY0Owo30gL790tiYff9Pb/sycXYE= +github.com/onflow/flow v0.3.4/go.mod h1:lzyAYmbu1HfkZ9cfnL5/sjrrsnJiUU8fRL26CqLP7+c= github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ= github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac= github.com/onflow/flow-core-contracts/lib/go/templates v1.4.0 h1:u2DAG8pk0xFH7TwS70t1gSZ/FtIIZWMSNyiu4SeXBYg= @@ -926,8 +926,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80m github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= -github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= -github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.4.9 h1:UfsWWqj6VQbEHvaw8kSGvIawCpEfz3gOGZfcdugNxVE= +github.com/onflow/flow/protobuf/go/flow v0.4.9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k= diff --git a/insecure/go.mod b/insecure/go.mod index 0aac4d360f6..4b36a53d0ab 100644 --- a/insecure/go.mod +++ b/insecure/go.mod @@ -210,7 +210,7 @@ require ( github.com/onflow/flow-go-sdk v1.3.0 // indirect github.com/onflow/flow-nft/lib/go/contracts v1.2.2 // indirect github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect - github.com/onflow/flow/protobuf/go/flow v0.4.7 // indirect + github.com/onflow/flow/protobuf/go/flow v0.4.9 // indirect github.com/onflow/go-ethereum v1.14.7 // indirect github.com/onflow/sdks v0.6.0-preview.1 // indirect github.com/onflow/wal v1.0.2 // indirect diff --git a/insecure/go.sum b/insecure/go.sum index aa133d48488..75e5ef92bfa 100644 --- a/insecure/go.sum +++ b/insecure/go.sum @@ -867,8 +867,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80m github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= -github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= -github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.4.9 h1:UfsWWqj6VQbEHvaw8kSGvIawCpEfz3gOGZfcdugNxVE= +github.com/onflow/flow/protobuf/go/flow v0.4.9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k= diff --git a/integration/go.mod b/integration/go.mod index cb3059397ce..14b1767ef32 100644 --- a/integration/go.mod +++ b/integration/go.mod @@ -27,7 +27,7 @@ require ( github.com/onflow/flow-go v0.38.0-preview.0.0.20241021221952-af9cd6e99de1 github.com/onflow/flow-go-sdk v1.3.0 github.com/onflow/flow-go/insecure v0.0.0-00010101000000-000000000000 - github.com/onflow/flow/protobuf/go/flow v0.4.7 + github.com/onflow/flow/protobuf/go/flow v0.4.9 github.com/onflow/go-ethereum v1.14.7 github.com/prometheus/client_golang v1.18.0 github.com/prometheus/client_model v0.5.0 diff --git a/integration/go.sum b/integration/go.sum index 0ce6b1985ce..53a457ac147 100644 --- a/integration/go.sum +++ b/integration/go.sum @@ -745,8 +745,8 @@ github.com/onflow/flow-nft/lib/go/contracts v1.2.2 h1:XFERNVUDGbZ4ViZjt7P1cGD80m github.com/onflow/flow-nft/lib/go/contracts v1.2.2/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY= github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE= github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI= -github.com/onflow/flow/protobuf/go/flow v0.4.7 h1:iP6DFx4wZ3ETORsyeqzHu7neFT3d1CXF6wdK+AOOjmc= -github.com/onflow/flow/protobuf/go/flow v0.4.7/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= +github.com/onflow/flow/protobuf/go/flow v0.4.9 h1:UfsWWqj6VQbEHvaw8kSGvIawCpEfz3gOGZfcdugNxVE= +github.com/onflow/flow/protobuf/go/flow v0.4.9/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk= github.com/onflow/go-ethereum v1.14.7 h1:gg3awYqI02e3AypRdpJKEvNTJ6kz/OhAqRti0h54Wlc= github.com/onflow/go-ethereum v1.14.7/go.mod h1:zV14QLrXyYu5ucvcwHUA0r6UaqveqbXaehAVQJlSW+I= github.com/onflow/sdks v0.6.0-preview.1 h1:mb/cUezuqWEP1gFZNAgUI4boBltudv4nlfxke1KBp9k=