Skip to content

Commit eafb4ed

Browse files
author
lemastero
committed
[ETCM-126] merge from develop & fix compile errors
2 parents 459a3fd + 8ae3eef commit eafb4ed

28 files changed

+858
-115
lines changed

build.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ scalacOptions := Seq(
8585
"-Xlint:unsound-match",
8686
"-Ywarn-inaccessible",
8787
"-Ywarn-unused-import",
88+
"-Ypartial-unification",
8889
"-encoding",
8990
"utf-8"
9091
)

insomnia_workspace.json

Lines changed: 130 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,95 @@
11
{
22
"_type": "export",
33
"__export_format": 4,
4-
"__export_date": "2020-09-30T20:01:40.792Z",
4+
"__export_date": "2020-10-02T11:18:34.806Z",
55
"__export_source": "insomnia.desktop.app:v2020.4.1",
66
"resources": [
7+
{
8+
"_id": "req_4222a4d54ba24fa7813429bdcdb732df",
9+
"parentId": "fld_a7212a5b96194230a7e0abc76ee2bf26",
10+
"modified": 1601637263922,
11+
"created": 1601637164399,
12+
"url": "{{ node_url }}",
13+
"name": "checkpointing_getLatestBlock",
14+
"description": "",
15+
"method": "POST",
16+
"body": {
17+
"mimeType": "application/json",
18+
"text": "{\n\t\"jsonrpc\": \"2.0\",\n\t\"id\": 1,\n\t\"method\": \"checkpointing_getLatestBlock\",\n\t\"params\": [5]\n}"
19+
},
20+
"parameters": [],
21+
"headers": [
22+
{
23+
"name": "Content-Type",
24+
"value": "application/json",
25+
"id": "pair_a28efff3b44442d99b7f3fbc54d8c9b6"
26+
}
27+
],
28+
"authentication": {},
29+
"metaSortKey": -1601637164399,
30+
"isPrivate": false,
31+
"settingStoreCookies": true,
32+
"settingSendCookies": true,
33+
"settingDisableRenderRequestBody": false,
34+
"settingEncodeUrl": true,
35+
"settingRebuildPath": true,
36+
"settingFollowRedirects": "global",
37+
"_type": "request"
38+
},
39+
{
40+
"_id": "fld_a7212a5b96194230a7e0abc76ee2bf26",
41+
"parentId": "wrk_097d43914a4d4aea8b6f73f647921182",
42+
"modified": 1601637156313,
43+
"created": 1601637156313,
44+
"name": "Checkpointing",
45+
"description": "",
46+
"environment": {},
47+
"environmentPropertyOrder": null,
48+
"metaSortKey": -1601637156313,
49+
"_type": "request_group"
50+
},
51+
{
52+
"_id": "wrk_097d43914a4d4aea8b6f73f647921182",
53+
"parentId": null,
54+
"modified": 1599825617921,
55+
"created": 1552662762769,
56+
"name": "Mantis",
57+
"description": "",
58+
"scope": null,
59+
"_type": "workspace"
60+
},
61+
{
62+
"_id": "req_da1e409360394849b673ec4e27f542b6",
63+
"parentId": "fld_a7212a5b96194230a7e0abc76ee2bf26",
64+
"modified": 1601637193229,
65+
"created": 1601637186866,
66+
"url": "{{ node_url }}",
67+
"name": "checkpointing_pushCheckpoint",
68+
"description": "",
69+
"method": "POST",
70+
"body": {
71+
"mimeType": "application/json",
72+
"text": "{\n\t\"jsonrpc\": \"2.0\",\n\t\"id\": 1,\n\t\"method\": \"checkpointing_pushCheckpoint\",\n\t\"params\": [\n\t\t\"127d6fde40d20208641c057a1ad4d12d44433881a660b15ac99f04f25762fb9b\",\n\t\t[\n\t\"2194b40851c648e7570e75ea2c507887d11c2270f7523469953fc5c3d5e0f50f48d73ea0b827eb81bb2fc0511f09d10b8f1d3f88e251ed231bb0f5cd03826d281b\",\n\t\t\t\"bbd4ae567202a6e7f40826c964a918760253596bb92052ea7ef4b30338b19fc12d56d497c88f0f13eff0ad542a8a4c1069559cb43e9741b849bf6577287450e31b\"\n\t\t]\n\t]\n}"
73+
},
74+
"parameters": [],
75+
"headers": [
76+
{
77+
"name": "Content-Type",
78+
"value": "application/json",
79+
"id": "pair_a28efff3b44442d99b7f3fbc54d8c9b6"
80+
}
81+
],
82+
"authentication": {},
83+
"metaSortKey": -1583661254601.5,
84+
"isPrivate": false,
85+
"settingStoreCookies": true,
86+
"settingSendCookies": true,
87+
"settingDisableRenderRequestBody": false,
88+
"settingEncodeUrl": true,
89+
"settingRebuildPath": true,
90+
"settingFollowRedirects": "global",
91+
"_type": "request"
92+
},
793
{
894
"_id": "req_cd0078ce4a034ebdbdf7dc9e20e78a29",
995
"parentId": "fld_2b54cbb84e244284b3ef752c5f805376",
@@ -54,14 +140,41 @@
54140
"_type": "request_group"
55141
},
56142
{
57-
"_id": "wrk_097d43914a4d4aea8b6f73f647921182",
58-
"parentId": null,
59-
"modified": 1599825617921,
60-
"created": 1552662762769,
61-
"name": "Mantis",
143+
"_id": "req_6197fefa1e1448a89f30712ec12295f8",
144+
"parentId": "fld_2b54cbb84e244284b3ef752c5f805376",
145+
"modified": 1600249571669,
146+
"created": 1600249491560,
147+
"url": "{{ node_url }}",
148+
"name": "qa_getPendingTransactions",
62149
"description": "",
63-
"scope": null,
64-
"_type": "workspace"
150+
"method": "POST",
151+
"body": {
152+
"mimeType": "application/json",
153+
"text": "{\n\t\"jsonrpc\": \"2.0\",\n \"method\": \"qa_getPendingTransactions\", \n \"params\": [],\n \"id\": 1\n}"
154+
},
155+
"parameters": [],
156+
"headers": [
157+
{
158+
"id": "pair_9f4d6a9dde554cd384487e04fa3b21aa",
159+
"name": "Content-Type",
160+
"value": "application/json"
161+
},
162+
{
163+
"id": "pair_088edc31f5e04f20a16b465a673871bb",
164+
"name": "Cache-Control",
165+
"value": "no-cache"
166+
}
167+
],
168+
"authentication": {},
169+
"metaSortKey": -1552939150156.832,
170+
"isPrivate": false,
171+
"settingStoreCookies": true,
172+
"settingSendCookies": true,
173+
"settingDisableRenderRequestBody": false,
174+
"settingEncodeUrl": true,
175+
"settingRebuildPath": true,
176+
"settingFollowRedirects": "global",
177+
"_type": "request"
65178
},
66179
{
67180
"_id": "req_dd6e5c718f974407bb79fe3c953b7106",
@@ -1034,12 +1147,18 @@
10341147
"modified": 1599825641645,
10351148
"created": 1552663140073,
10361149
"name": "Develop",
1037-
"data": { "node_url": "http://127.0.0.1:8546" },
1038-
"dataPropertyOrder": { "&": ["node_url"] },
1150+
"data": {
1151+
"node_url": "http://127.0.0.1:8546"
1152+
},
1153+
"dataPropertyOrder": {
1154+
"&": [
1155+
"node_url"
1156+
]
1157+
},
10391158
"color": null,
10401159
"isPrivate": false,
10411160
"metaSortKey": 1552663140073,
10421161
"_type": "environment"
10431162
}
10441163
]
1045-
}
1164+
}

nix/default.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ let
1717

1818
inherit (final.mantisPkgs) mantis;
1919

20-
inherit (final.mantisPkgs) mantis-unwrapped;
20+
mkSrc = import sources.nix-mksrc { inherit (final) lib; };
2121
};
2222
in import sources.nixpkgs {
2323
inherit system;

nix/pkgs/mantis/default.nix

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,4 @@
1-
{ src, lib, gitignoreSource, callPackage, jre }: rec {
2-
3-
mkSrc = src:
4-
let
5-
isGit = builtins.pathExists (src + "/.git");
6-
repo = builtins.fetchGit { url = src; submodules = true; };
7-
dirty = repo.revCount == 0;
8-
filterSrc = src:
9-
lib.cleanSourceWith {
10-
inherit src;
11-
filter = path: _: !lib.hasSuffix "nix" path;
12-
};
13-
in if isGit then
14-
if dirty then filterSrc (gitignoreSource src) else repo
15-
else
16-
src;
1+
{ src, mkSrc, lib, gitignoreSource, callPackage, jre }: rec {
172

183
mantis-source = mkSrc src;
194

nix/sources.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@
3535
"url": "https://github.com/nmattia/niv/archive/f73bf8d584148677b01859677a63191c31911eae.tar.gz",
3636
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
3737
},
38+
"nix-mksrc": {
39+
"branch": "master",
40+
"description": null,
41+
"homepage": "",
42+
"owner": "input-output-hk",
43+
"repo": "nix-mksrc",
44+
"rev": "c446c2da50209f06d75df9f06f9faa738939b54d",
45+
"sha256": "1mnp88fvg9rkl211zsg1mjkx0kk63l9q4fdy3a4avbq8z9bjb1gf",
46+
"type": "tarball",
47+
"url": "https://github.com/input-output-hk/nix-mksrc/archive/c446c2da50209f06d75df9f06f9faa738939b54d.tar.gz",
48+
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
49+
},
3850
"nixkite": {
3951
"branch": "master",
4052
"description": "Nixkite is a Buildkite pipeline generation tool using the NixOS module system",

src/it/scala/io/iohk/ethereum/txExecTest/util/DumpChainApp.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,13 @@ object DumpChainApp extends App with NodeKeyBuilder with SecureRandomBuilder wit
162162

163163
def saveBlockNumber(number: BigInt, hash: NodeHash): Unit = ???
164164

165-
def saveBestKnownBlock(number: BigInt): Unit = ???
165+
def saveBestKnownBlocks(bestBlockNumber: BigInt, latestCheckpointNumber: Option[BigInt] = None): Unit = ???
166166

167167
def getBestBlock(): Block = ???
168168

169169
override def save(block: Block, receipts: Seq[Receipt], totalDifficulty: BigInt, saveAsBestBlock: Boolean): Unit = ???
170170

171171
override def getStateStorage: StateStorage = ???
172+
173+
override def getLatestCheckpointBlockNumber(): BigInt = ???
172174
}

src/main/resources/application.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ mantis {
185185
}
186186

187187
# Enabled JSON-RPC APIs over the JSON-RPC endpoint
188-
# Available choices are: eth, web3, net, personal, test, daedalus, iele, qa
189-
apis = "eth,web3,net,personal,daedalus,debug,qa"
188+
# Available choices are: web3, eth, net, personal, daedalus, test, iele, debug, qa, checkpointing
189+
apis = "eth,web3,net,personal,daedalus,debug,qa,checkpointing"
190190

191191
# Maximum number of blocks for daedalus_getAccountTransactions
192192
account-transactions-max-blocks = 50000

src/main/scala/io/iohk/ethereum/blockchain/sync/FastSync.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ class FastSync(
280280
blockchain.removeBlock(headerToRemove.hash, withState = false)
281281
}
282282
}
283+
// TODO (maybe ETCM-77): Manage last checkpoint number too
283284
appStateStorage.putBestBlockNumber((startBlock - blocksToDiscard - 1) max 0).commit()
284285
}
285286

src/main/scala/io/iohk/ethereum/blockchain/sync/regular/RegularSync.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package io.iohk.ethereum.blockchain.sync.regular
22

33
import akka.actor.{Actor, ActorLogging, ActorRef, AllForOneStrategy, Cancellable, Props, Scheduler, SupervisorStrategy}
4+
import akka.util.ByteString
45
import io.iohk.ethereum.blockchain.sync.BlockBroadcast
6+
import io.iohk.ethereum.crypto.ECDSASignature
57
import io.iohk.ethereum.domain.{Block, Blockchain}
68
import io.iohk.ethereum.ledger.Ledger
79
import io.iohk.ethereum.utils.Config.SyncConfig
@@ -95,4 +97,5 @@ object RegularSync {
9597
sealed trait RegularSyncMsg
9698
case object Start extends RegularSyncMsg
9799
case class MinedBlock(block: Block) extends RegularSyncMsg
100+
case class NewCheckpoint(parentHash: ByteString, signatures: Seq[ECDSASignature]) extends RegularSyncMsg
98101
}

src/main/scala/io/iohk/ethereum/db/storage/StateStorage.scala

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ trait StateStorage {
1818
def getBackingStorage(bn: BigInt): MptStorage
1919
def getReadOnlyStorage: MptStorage
2020

21-
def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit
22-
def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit
21+
def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit
22+
def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit
2323

2424
def saveNode(nodeHash: NodeHash, nodeEncoded: NodeEncoded, bn: BigInt)
2525
def getNode(nodeHash: NodeHash): Option[MptNode]
@@ -34,15 +34,15 @@ class ArchiveStateStorage(private val nodeStorage: NodeStorage,
3434
true
3535
}
3636

37-
override def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit = {
37+
override def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit = {
3838
if (cachedNodeStorage.persist()) {
39-
updateBestBlock(None)
39+
updateBestBlocksData()
4040
}
4141
}
4242

43-
override def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit = {
43+
override def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit = {
4444
if (cachedNodeStorage.persist()) {
45-
updateBestBlock(None)
45+
updateBestBlocksData()
4646
}
4747
}
4848

@@ -71,21 +71,21 @@ class ReferenceCountedStateStorage(private val nodeStorage: NodeStorage,
7171
true
7272
}
7373

74-
override def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit = {
74+
override def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit = {
7575
val blockToPrune = bn - pruningHistory
7676

7777
ReferenceCountNodeStorage.prune(blockToPrune, cachedNodeStorage, inMemory = blockToPrune > currentBestSavedBlock)
7878

7979
if (cachedNodeStorage.persist()) {
80-
updateBestBlock(None)
80+
updateBestBlocksData()
8181
}
8282
}
8383

84-
override def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit = {
84+
override def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit = {
8585
ReferenceCountNodeStorage.rollback(bn, cachedNodeStorage, inMemory = bn > currentBestSavedBlock)
8686

8787
if (cachedNodeStorage.persist()) {
88-
updateBestBlock(None)
88+
updateBestBlocksData()
8989
}
9090
}
9191

@@ -120,19 +120,19 @@ class CachedReferenceCountedStateStorage(private val nodeStorage: NodeStorage,
120120
}
121121
}
122122

123-
override def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit = {
123+
override def onBlockSave(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit = {
124124
val blockToPrune = bn - pruningHistory
125125
changeLog.persistChangeLog(bn)
126126
changeLog.getDeathRowFromStorage(blockToPrune).foreach {deathRow =>
127127
CachedReferenceCountedStorage.prune(deathRow, lruCache, blockToPrune)
128128
}
129129
if (CachedReferenceCountedStorage.persistCache(lruCache, nodeStorage)) {
130-
updateBestBlock(None)
130+
updateBestBlocksData()
131131
}
132132
changeLog.removeBlockMetaData(blockToPrune)
133133
}
134134

135-
override def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlock: Option[BigInt] => Unit): Unit = {
135+
override def onBlockRollback(bn: BigInt, currentBestSavedBlock: BigInt)(updateBestBlocksData: () => Unit): Unit = {
136136
changeLog.getChangeLogFromStorage(bn).foreach { changeLog =>
137137
CachedReferenceCountedStorage.rollback(lruCache, nodeStorage, changeLog, bn)
138138
}

src/main/scala/io/iohk/ethereum/domain/Block.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ case class Block(header: BlockHeader, body: BlockBody) {
2525

2626
def hash: ByteString = header.hash
2727

28+
val hasCheckpoint: Boolean = header.hasCheckpoint
29+
2830
def isParentOf(child: Block): Boolean = number + 1 == child.number && child.header.parentHash == hash
2931
}
3032

0 commit comments

Comments
 (0)