Skip to content

Commit 87d6a7e

Browse files
authored
Use Pebble backend for consensus follower (#92)
* Use pebble DB backend for consensus follower * Use pebble DB backend for indexDB * Use zerolog in indexdb * Use storage with badger backend for cache Pebble does not support the `DropAll` method. * Revert storage layer updates for cache and indexDB * update flow-go to v0.43.0-rc.1 * Revert logging changes for consistency * clean up whitespace in Makefile * Update rosetta_handler.py - Single definition of the network identifier - Slightly improve error displayed if preprocess_transaction fails * apply suggestions from AI * update flow-go to v0.43.0-rc.2
1 parent 71bd8c2 commit 87d6a7e

File tree

5 files changed

+67
-70
lines changed

5 files changed

+67
-70
lines changed

Makefile

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ gen-originator-account:
4343
} \
4444
}' "${FLOW_JSON}" > flow.json.tmp && mv flow.json.tmp "${FLOW_JSON}" || { echo "Failed to update ${FLOW_JSON} with jq"; exit 1; }; \
4545
jq --arg address "$$address" '.originators += [$$address]' "${ROSETTA_ENV}.json" > env.json.tmp && mv env.json.tmp "${ROSETTA_ENV}.json"; \
46-
echo "$(ACCOUNT_NAME),$$KEYS,0x$$address" >> $(ACCOUNT_KEYS_FILENAME); \
46+
echo "$(ACCOUNT_NAME),$$KEYS,0x$$address" >> $(ACCOUNT_KEYS_FILENAME); \
4747
echo "Updated $(FLOW_JSON), $(ROSETTA_ENV).json and $(ACCOUNT_KEYS_FILENAME)";
4848

4949
.PHONY: fund-accounts
@@ -67,22 +67,22 @@ create-originator-derived-account:
6767
ROOT_ORIGINATOR_PUBLIC_KEY=$$(grep '$(ORIGINATOR_NAME)' $(ACCOUNT_KEYS_FILENAME) | cut -d ',' -f2); \
6868
ROOT_ORIGINATOR_PRIVATE_KEY=$$(grep '$(ORIGINATOR_NAME)' $(ACCOUNT_KEYS_FILENAME) | cut -d ',' -f4 ); \
6969
ROOT_ORIGINATOR_ADDRESS=$$(grep '$(ORIGINATOR_NAME)' $(ACCOUNT_KEYS_FILENAME) | cut -d ',' -f5); \
70-
echo "Originator address: $$ROOT_ORIGINATOR_ADDRESS"; \
71-
TX_HASH=$$(python3 rosetta_handler.py rosetta-create-derived-account $(ROSETTA_HOST_URL) $$ROOT_ORIGINATOR_ADDRESS $$ROOT_ORIGINATOR_PUBLIC_KEY $$ROOT_ORIGINATOR_PRIVATE_KEY $$NEW_ACCOUNT_PUBLIC_ROSETTA_KEY); \
70+
echo "Originator address: $$ROOT_ORIGINATOR_ADDRESS"; \
71+
TX_HASH=$$(python3 rosetta_handler.py rosetta-create-derived-account $(ROSETTA_HOST_URL) $$ROOT_ORIGINATOR_ADDRESS $$ROOT_ORIGINATOR_PUBLIC_KEY $$ROOT_ORIGINATOR_PRIVATE_KEY $$NEW_ACCOUNT_PUBLIC_ROSETTA_KEY); \
7272
ADDRESS=$$(flow transactions get $$TX_HASH -f $(FLOW_JSON) -n $(ROSETTA_ENV) -o json | jq -r '.events[] | select(.type == "flow.AccountCreated") | .values.value.fields[] | select(.name == "address") | .value.value'); \
7373
echo "TX_HASH: $$TX_HASH , ADDRESS: $$ADDRESS"; \
74-
echo "$(NEW_ACCOUNT_NAME),$$NEW_ACCOUNT_PUBLIC_FLOW_KEY,$$NEW_ACCOUNT_PUBLIC_ROSETTA_KEY,$$NEW_ACCOUNT_PRIVATE_KEY,$$ADDRESS" >> $(ACCOUNT_KEYS_FILENAME);
74+
echo "$(NEW_ACCOUNT_NAME),$$NEW_ACCOUNT_PUBLIC_FLOW_KEY,$$NEW_ACCOUNT_PUBLIC_ROSETTA_KEY,$$NEW_ACCOUNT_PRIVATE_KEY,$$ADDRESS" >> $(ACCOUNT_KEYS_FILENAME);
7575

7676
.PHONY: rosetta-transfer-funds
7777
rosetta-transfer-funds:
7878
PAYER_PUBLIC_KEY=$$(grep '$(PAYER_NAME)' $(ACCOUNT_KEYS_FILENAME) | cut -d ',' -f2); \
7979
PAYER_PRIVATE_KEY=$$(grep '$(PAYER_NAME)' $(ACCOUNT_KEYS_FILENAME) | cut -d ',' -f4 ); \
8080
PAYER_ADDRESS=$$(grep '$(PAYER_NAME)' $(ACCOUNT_KEYS_FILENAME) | cut -d ',' -f5); \
81-
echo "Payer address: $$PAYER_ADDRESS"; \
81+
echo "Payer address: $$PAYER_ADDRESS"; \
8282
RECIPIENT_ADDRESS=$$(grep '$(RECIPIENT_NAME)' $(ACCOUNT_KEYS_FILENAME) | cut -d ',' -f5); \
83-
echo "Recipient address: $$RECIPIENT_ADDRESS"; \
84-
TX_HASH=$$(python3 rosetta_handler.py rosetta-transfer-funds $(ROSETTA_HOST_URL) $$PAYER_ADDRESS $$PAYER_PUBLIC_KEY $$PAYER_PRIVATE_KEY $$RECIPIENT_ADDRESS $$AMOUNT); \
85-
echo "Funding sent: $$TX_HASH";
83+
echo "Recipient address: $$RECIPIENT_ADDRESS"; \
84+
TX_HASH=$$(python3 rosetta_handler.py rosetta-transfer-funds $(ROSETTA_HOST_URL) $$PAYER_ADDRESS $$PAYER_PUBLIC_KEY $$PAYER_PRIVATE_KEY $$RECIPIENT_ADDRESS $$AMOUNT); \
85+
echo "Funding sent: $$TX_HASH";
8686

8787
# Use this target to verify that the accounts configured in the Rosetta environment JSON have the specified contracts deployed
8888
.PHONY: verify-configured-contract-addresses
@@ -92,22 +92,22 @@ verify-configured-contract-addresses:
9292
KEY=$$(echo $$contract | cut -d= -f1); \
9393
VALUE=$$(echo $$contract | cut -d= -f2); \
9494
if [ "$$VALUE" = "0000000000000000" ]; then \
95-
continue; \
96-
fi; \
95+
continue; \
96+
fi; \
9797
CONTRACTS_FOUND=$$(flow accounts get $$VALUE -f $(FLOW_JSON) -n $(ROSETTA_ENV) -o json | \
9898
jq -r '.contracts | join(",") '); \
9999
found=false ; \
100100
for contract in $$(echo $$CONTRACTS_FOUND | tr ',' ' '); do \
101-
lowercase_contract_name=$$(echo $$contract | tr '[:upper:]' '[:lower:]'); \
102-
if [ "$$KEY" = "$$lowercase_contract_name" ]; then \
103-
found=true ; \
104-
break; \
105-
fi; \
106-
done; \
107-
if [ "$$found" = "false" ]; then \
108-
echo "Contract $$KEY configured in $(ROSETTA_ENV).json is not deployed to configured address $$VALUE" ;\
101+
lowercase_contract_name=$$(echo $$contract | tr '[:upper:]' '[:lower:]'); \
102+
if [ "$$KEY" = "$$lowercase_contract_name" ]; then \
103+
found=true ; \
104+
break; \
105+
fi; \
106+
done; \
107+
if [ "$$found" = "false" ]; then \
108+
echo "Contract $$KEY configured in $(ROSETTA_ENV).json is not deployed to configured address $$VALUE" ;\
109109
fi; \
110-
done ; \
110+
done ;
111111

112112
.PHONY: build
113113
build: go-test go-build
@@ -139,4 +139,4 @@ test-reset:
139139
test-cleanup: test-reset
140140
rm -f flow.json
141141
rm -f account-keys.csv
142-
rm -rf flow-go
142+
rm -rf flow-go

go.mod

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ require (
66
github.com/coinbase/rosetta-sdk-go v0.8.9
77
github.com/coinbase/rosetta-sdk-go/types v1.0.0
88
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.3.0
9-
github.com/dgraph-io/badger/v2 v2.2007.4
109
github.com/dgraph-io/badger/v3 v3.2103.2
1110
github.com/ethereum/go-ethereum v1.16.3
1211
github.com/golang/protobuf v1.5.4
1312
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0
1413
github.com/libp2p/go-libp2p v0.38.2
1514
github.com/onflow/cadence v1.7.0
1615
github.com/onflow/crypto v0.25.3
17-
github.com/onflow/flow-go v0.43.0-dev-pebble.1.0.20250910132853-12699a150fd9
18-
github.com/onflow/flow/protobuf/go/flow v0.4.12
16+
github.com/onflow/flow-go v0.43.0-rc.2
17+
github.com/onflow/flow/protobuf/go/flow v0.4.15
1918
github.com/rs/zerolog v1.29.0
2019
github.com/stretchr/testify v1.11.1
2120
go.opentelemetry.io/otel v1.37.0
@@ -49,6 +48,7 @@ require (
4948
github.com/cockroachdb/swiss v0.0.0-20250624142022-d6e517c1d961 // indirect
5049
github.com/crate-crypto/go-eth-kzg v1.3.0 // indirect
5150
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect
51+
github.com/dgraph-io/badger/v2 v2.2007.4 // indirect
5252
github.com/emicklei/dot v1.6.2 // indirect
5353
github.com/envoyproxy/go-control-plane/envoy v1.32.4 // indirect
5454
github.com/envoyproxy/protoc-gen-validate v1.2.1 // indirect
@@ -69,7 +69,7 @@ require (
6969
github.com/onflow/fixed-point v0.1.1 // indirect
7070
github.com/onflow/flow-evm-bridge v0.1.0 // indirect
7171
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
72-
github.com/onflow/flow-nft/lib/go/templates v1.2.1 // indirect
72+
github.com/onflow/flow-nft/lib/go/templates v1.3.0 // indirect
7373
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 // indirect
7474
github.com/pion/datachannel v1.5.10 // indirect
7575
github.com/pion/dtls/v2 v2.2.12 // indirect
@@ -203,7 +203,6 @@ require (
203203
github.com/ipfs/go-cid v0.4.1 // indirect
204204
github.com/ipfs/go-cidutil v0.1.0 // indirect
205205
github.com/ipfs/go-datastore v0.8.2 // indirect
206-
github.com/ipfs/go-ds-badger2 v0.1.4 // indirect
207206
github.com/ipfs/go-ipfs-delay v0.0.1 // indirect
208207
github.com/ipfs/go-ipfs-pq v0.0.3 // indirect
209208
github.com/ipfs/go-ipfs-util v0.0.3 // indirect
@@ -263,11 +262,11 @@ require (
263262
github.com/multiformats/go-varint v0.0.7 // indirect
264263
github.com/olekukonko/tablewriter v0.0.5 // indirect
265264
github.com/onflow/atree v0.10.1 // indirect
266-
github.com/onflow/flow-core-contracts/lib/go/contracts v1.7.4-0.20250825173510-91e6f28b0224 // indirect; v1.2.4-0.20230703193002-53362441b57d // indirect
267-
github.com/onflow/flow-core-contracts/lib/go/templates v1.7.2-0.20250825173510-91e6f28b0224 // indirect; v1.2.3 // indirect
265+
github.com/onflow/flow-core-contracts/lib/go/contracts v1.8.0 // indirect; v1.2.4-0.20230703193002-53362441b57d // indirect
266+
github.com/onflow/flow-core-contracts/lib/go/templates v1.8.0 // indirect; v1.2.3 // indirect
268267
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
269268
github.com/onflow/flow-go-sdk v1.8.1 // indirect
270-
github.com/onflow/flow-nft/lib/go/contracts v1.2.4 // indirect
269+
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 // indirect
271270
github.com/onflow/go-ethereum v1.16.2 // indirect
272271
github.com/onflow/sdks v0.6.0-preview.1 // indirect
273272
github.com/onflow/wal v1.0.2 // indirect

go.sum

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,6 @@ github.com/ipfs/go-datastore v0.8.2 h1:Jy3wjqQR6sg/LhyY0NIePZC3Vux19nLtg7dx0TVqr
540540
github.com/ipfs/go-datastore v0.8.2/go.mod h1:W+pI1NsUsz3tcsAACMtfC+IZdnQTnC/7VfPoJBQuts0=
541541
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
542542
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
543-
github.com/ipfs/go-ds-badger2 v0.1.4 h1:4EDTEDV/Ft/zr5AaJXp2IojvApwevlUD9uahMDONWTE=
544-
github.com/ipfs/go-ds-badger2 v0.1.4/go.mod h1:6WOt9PzJ98Tu7gizJ35NuXDORsYxQ3c4/3gjqF+kq0c=
545543
github.com/ipfs/go-ds-pebble v0.5.0 h1:lXffYCAKVD7nLLPqwJ9D8IxgO7Kz8woiX021tezdsIM=
546544
github.com/ipfs/go-ds-pebble v0.5.0/go.mod h1:aiCRVcj3K60sxc6k5C+HO9C6rouqiSkjR/WKnbTcMfQ=
547545
github.com/ipfs/go-ipfs-blocksutil v0.0.1 h1:Eh/H4pc1hsvhzsQoMEP3Bke/aW5P5rVM1IWFJMcGIPQ=
@@ -739,26 +737,26 @@ github.com/onflow/crypto v0.25.3 h1:XQ3HtLsw8h1+pBN+NQ1JYM9mS2mVXTyg55OldaAIF7U=
739737
github.com/onflow/crypto v0.25.3/go.mod h1:+1igaXiK6Tjm9wQOBD1EGwW7bYWMUGKtwKJ/2QL/OWs=
740738
github.com/onflow/fixed-point v0.1.1 h1:j0jYZVO8VGyk1476alGudEg7XqCkeTVxb5ElRJRKS90=
741739
github.com/onflow/fixed-point v0.1.1/go.mod h1:gJdoHqKtToKdOZbvryJvDZfcpzC7d2fyWuo3ZmLtcGY=
742-
github.com/onflow/flow-core-contracts/lib/go/contracts v1.7.4-0.20250825173510-91e6f28b0224 h1:YKdTSG+6uu+dZpKCB2fmNWOmKGLn7+0MxFbtUFZdBjc=
743-
github.com/onflow/flow-core-contracts/lib/go/contracts v1.7.4-0.20250825173510-91e6f28b0224/go.mod h1:/Yne6g7V2Fy1sm/vE78us221bYvVvL5cA8cOzN/uTCI=
744-
github.com/onflow/flow-core-contracts/lib/go/templates v1.7.2-0.20250825173510-91e6f28b0224 h1:6ZBTrqPQIbnek7mdtJwbQux87qcJPTz82DDgGhpsHzI=
745-
github.com/onflow/flow-core-contracts/lib/go/templates v1.7.2-0.20250825173510-91e6f28b0224/go.mod h1:yBkysayvSKZ/yFO3fEX4YQ/FEZtV6Tnov8ix0lBeiqM=
740+
github.com/onflow/flow-core-contracts/lib/go/contracts v1.8.0 h1:Kq6MRKwmHfoTTDty/Ib7is1peaSMBQ2GHcnhDgsRH4c=
741+
github.com/onflow/flow-core-contracts/lib/go/contracts v1.8.0/go.mod h1:h15J7unHnlTARjudbb0m5KO3EoHIucoBgShAqE6NoNA=
742+
github.com/onflow/flow-core-contracts/lib/go/templates v1.8.0 h1:vcCIJP8vYuo0t77Hbxh2IEpGSZoEudB58Qpci11LSCE=
743+
github.com/onflow/flow-core-contracts/lib/go/templates v1.8.0/go.mod h1:twSVyUt3rNrgzAmxtBX+1Gw64QlPemy17cyvnXYy1Ug=
746744
github.com/onflow/flow-evm-bridge v0.1.0 h1:7X2osvo4NnQgHj8aERUmbYtv9FateX8liotoLnPL9nM=
747745
github.com/onflow/flow-evm-bridge v0.1.0/go.mod h1:5UYwsnu6WcBNrwitGFxphCl5yq7fbWYGYuiCSTVF6pk=
748746
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 h1:Ts5ob+CoCY2EjEd0W6vdLJ7hLL3SsEftzXG2JlmSe24=
749747
github.com/onflow/flow-ft/lib/go/contracts v1.0.1/go.mod h1:PwsL8fC81cjnUnTfmyL/HOIyHnyaw/JA474Wfj2tl6A=
750748
github.com/onflow/flow-ft/lib/go/templates v1.0.1 h1:FDYKAiGowABtoMNusLuRCILIZDtVqJ/5tYI4VkF5zfM=
751749
github.com/onflow/flow-ft/lib/go/templates v1.0.1/go.mod h1:uQ8XFqmMK2jxyBSVrmyuwdWjTEb+6zGjRYotfDJ5pAE=
752-
github.com/onflow/flow-go v0.43.0-dev-pebble.1.0.20250910132853-12699a150fd9 h1:LzgHQI7A8rINyfzKEF6x2gsrzx7zGBQpmgdHJjJtQqM=
753-
github.com/onflow/flow-go v0.43.0-dev-pebble.1.0.20250910132853-12699a150fd9/go.mod h1:VkvpX4p4imUpPR+FhL0Qw7Qx32zQ/QOQRz2Vl2uu50Y=
750+
github.com/onflow/flow-go v0.43.0-rc.2 h1:U0yhR9asL/4tTIbGq7vrBEwUr6JFupNRySSRU4EM5jc=
751+
github.com/onflow/flow-go v0.43.0-rc.2/go.mod h1:zz8rd/tod51kd33im9x6uDmGiyeb5qCZhKr7g01/wgI=
754752
github.com/onflow/flow-go-sdk v1.8.1 h1:BPp7p10RrpOdezQ3RJ+nheOqpalHlTB9bRocVkLsGNU=
755753
github.com/onflow/flow-go-sdk v1.8.1/go.mod h1:w6bxCznDhJJCDybn1jCUAz3rEO4/7XY9EgWRFrj0zoo=
756-
github.com/onflow/flow-nft/lib/go/contracts v1.2.4 h1:gWJgSSgIGo0qWOqr90+khQ69VoYF9vNlqzF+Yh6YYy4=
757-
github.com/onflow/flow-nft/lib/go/contracts v1.2.4/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY=
758-
github.com/onflow/flow-nft/lib/go/templates v1.2.1 h1:SAALMZPDw9Eb9p5kSLnmnFxjyig1MLiT4JUlLp0/bSE=
759-
github.com/onflow/flow-nft/lib/go/templates v1.2.1/go.mod h1:W6hOWU0xltPqNpv9gQX8Pj8Jtf0OmRxc1XX2V0kzJaI=
760-
github.com/onflow/flow/protobuf/go/flow v0.4.12 h1:nMJHVuz2iRQnzEwvmruCaMrQvm/dfdWtbKroi3o/42M=
761-
github.com/onflow/flow/protobuf/go/flow v0.4.12/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
754+
github.com/onflow/flow-nft/lib/go/contracts v1.3.0 h1:DmNop+O0EMyicZvhgdWboFG57xz5t9Qp81FKlfKyqJc=
755+
github.com/onflow/flow-nft/lib/go/contracts v1.3.0/go.mod h1:eZ9VMMNfCq0ho6kV25xJn1kXeCfxnkhj3MwF3ed08gY=
756+
github.com/onflow/flow-nft/lib/go/templates v1.3.0 h1:uGIBy4GEY6Z9hKP7sm5nA5kwvbvLWW4nWx5NN9Wg0II=
757+
github.com/onflow/flow-nft/lib/go/templates v1.3.0/go.mod h1:gVbb5fElaOwKhV5UEUjM+JQTjlsguHg2jwRupfM/nng=
758+
github.com/onflow/flow/protobuf/go/flow v0.4.15 h1:7Xt7kkqeeygWMw/S327uKu11FPJghNm1pvam2HXbC7g=
759+
github.com/onflow/flow/protobuf/go/flow v0.4.15/go.mod h1:NA2pX2nw8zuaxfKphhKsk00kWLwfd+tv8mS23YXO4Sk=
762760
github.com/onflow/go-ethereum v1.16.2 h1:yhC3DA5PTNmUmu7ziq8GmWyQ23KNjle4jCabxpKYyNk=
763761
github.com/onflow/go-ethereum v1.16.2/go.mod h1:1vsrG/9APHPqt+mVFni60hIXkqkVdU9WQayNjYi/Ah4=
764762
github.com/onflow/nft-storefront/lib/go/contracts v1.0.0 h1:sxyWLqGm/p4EKT6DUlQESDG1ZNMN9GjPCm1gTq7NGfc=

rosetta_handler.py

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
def cli():
1212
pass
1313

14+
network_identifier = {
15+
"blockchain": "flow",
16+
"network": "localnet",
17+
}
1418

1519
# Shared function used internally but not standalone from CLI
1620

@@ -24,10 +28,7 @@ def preprocess_transaction(rosetta_host_url, root_originator, operations, metada
2428
endpoint = "/construction/preprocess"
2529
target_url = rosetta_host_url + endpoint
2630
data = {
27-
"network_identifier": {
28-
"blockchain": "flow",
29-
"network": "localnet"
30-
},
31+
"network_identifier": network_identifier,
3132
"operations": operations,
3233
"metadata": {
3334
"payer": root_originator
@@ -36,17 +37,17 @@ def preprocess_transaction(rosetta_host_url, root_originator, operations, metada
3637
if metadata:
3738
for key in metadata:
3839
data["metadata"][key] = metadata[key]
39-
return request_router(target_url, data)
40+
result = request_router(target_url, data)
41+
if "options" not in result:
42+
raise RuntimeError(result)
43+
return result
4044

4145

4246
def metadata_transaction(rosetta_host_url, options):
4347
endpoint = "/construction/metadata"
4448
target_url = rosetta_host_url + endpoint
4549
data = {
46-
"network_identifier": {
47-
"blockchain": "flow",
48-
"network": "localnet"
49-
},
50+
"network_identifier": network_identifier,
5051
"options": options
5152
}
5253
return request_router(target_url, data)
@@ -56,10 +57,7 @@ def payloads_transaction(rosetta_host_url, operations, protobuf):
5657
endpoint = "/construction/payloads"
5758
target_url = rosetta_host_url + endpoint
5859
data = {
59-
"network_identifier": {
60-
"blockchain": "flow",
61-
"network": "localnet"
62-
},
60+
"network_identifier": network_identifier,
6361
"operations": operations,
6462
"metadata": {
6563
"protobuf": protobuf
@@ -72,10 +70,7 @@ def combine_transaction(rosetta_host_url, unsigned_tx, root_originator, hex_byte
7270
endpoint = "/construction/combine"
7371
target_url = rosetta_host_url + endpoint
7472
data = {
75-
"network_identifier": {
76-
"blockchain": "flow",
77-
"network": "localnet"
78-
},
73+
"network_identifier": network_identifier,
7974
"unsigned_transaction": unsigned_tx,
8075
"signatures": [
8176
{
@@ -103,10 +98,7 @@ def submit_transaction(rosetta_host_url, signed_tx):
10398
endpoint = "/construction/submit"
10499
target_url = rosetta_host_url + endpoint
105100
data = {
106-
"network_identifier": {
107-
"blockchain": "flow",
108-
"network": "localnet"
109-
},
101+
"network_identifier": network_identifier,
110102
"signed_transaction": signed_tx
111103
}
112104
return request_router(target_url, data)

state/state.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import (
1515
"sync"
1616
"time"
1717

18-
"github.com/dgraph-io/badger/v2"
1918
flowcrypto "github.com/onflow/crypto"
2019
"github.com/onflow/flow-go/cmd/bootstrap/utils"
2120
hotstuff "github.com/onflow/flow-go/consensus/hotstuff/model"
@@ -25,13 +24,15 @@ import (
2524
"github.com/onflow/flow-go/module/compliance"
2625
"github.com/onflow/flow-go/storage"
2726
"github.com/onflow/flow-go/storage/operation"
28-
"github.com/onflow/flow-go/storage/operation/badgerimpl"
27+
"github.com/onflow/flow-go/storage/operation/pebbleimpl"
28+
"github.com/onflow/flow-go/storage/pebble"
2929
"github.com/onflow/rosetta/cache"
3030
"github.com/onflow/rosetta/config"
3131
"github.com/onflow/rosetta/indexdb"
3232
"github.com/onflow/rosetta/log"
3333
"github.com/onflow/rosetta/model"
3434
"github.com/onflow/rosetta/process"
35+
zerolog "github.com/rs/zerolog/log"
3536
"golang.org/x/crypto/openpgp"
3637
"golang.org/x/crypto/openpgp/armor"
3738
"google.golang.org/grpc/codes"
@@ -636,12 +637,19 @@ func (i *Indexer) runConsensusFollower(ctx context.Context) {
636637
sporkDir := i.Chain.PathFor(spork.String())
637638
i.downloadRootState(ctx, spork, sporkDir)
638639
dbDir := filepath.Join(sporkDir, "consensus")
639-
opts := badger.DefaultOptions(dbDir).WithLogger(log.Badger{Prefix: "consensus"})
640-
db, err := badger.Open(opts)
640+
641+
dbLog := zerolog.With().Str("pebbledb", "consensusFollower").Logger()
642+
db, err := pebble.SafeOpen(dbLog, dbDir)
641643
if err != nil {
642644
log.Fatalf("Failed to open consensus database at %s: %s", dbDir, err)
643645
}
644-
protocolDB := badgerimpl.ToDB(db)
646+
process.SetExitHandler(func() {
647+
log.Infof("Closing the consensus follower database")
648+
if err := db.Close(); err != nil {
649+
log.Errorf("Got error closing the consensus follower database: %s", err)
650+
}
651+
})
652+
protocolDB := pebbleimpl.ToDB(db)
645653
// Initialize a private key for joining the unstaked peer-to-peer network.
646654
// This can be ephemeral, so we generate a new one each time we start.
647655
seed := make([]byte, flowcrypto.KeyGenSeedMinLen)
@@ -657,11 +665,11 @@ func (i *Indexer) runConsensusFollower(ctx context.Context) {
657665
for _, node := range spork.Consensus.SeedNodes {
658666
rawkey, err := hex.DecodeString(node.PublicKey)
659667
if err != nil {
660-
log.Fatalf("Failed to hex decode the seed node key %q: %s", key, err)
668+
log.Fatalf("Failed to hex decode the seed node key %q: %s", node.PublicKey, err)
661669
}
662670
pubkey, err := flowcrypto.DecodePublicKey(flowcrypto.ECDSAP256, rawkey)
663671
if err != nil {
664-
log.Fatalf("Failed to decode the seed node key %q: %s", key, err)
672+
log.Fatalf("Failed to decode the seed node key %q: %s", rawkey, err)
665673
}
666674
nodes = append(nodes, follower.BootstrapNodeInfo{
667675
Host: node.Host,

0 commit comments

Comments
 (0)