Skip to content

Commit

Permalink
Merge pull request #1171 from ergoplatform/v3.3.1
Browse files Browse the repository at this point in the history
Candidate for 3.3.1
  • Loading branch information
kushti authored Aug 19, 2020
2 parents c05a174 + 2d92711 commit 0c18522
Show file tree
Hide file tree
Showing 39 changed files with 410 additions and 275 deletions.
5 changes: 2 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ lazy val commonSettings = Seq(
publishTo := sonatypePublishToBundle.value,
)

val scorexVersion = "master-07d30caa-SNAPSHOT"
val scorexVersion = "master-bb48da3a-SNAPSHOT"
val sigmaStateVersion = "3.2.1"

// for testing current sigmastate build (see sigmastate-ergo-it jenkins job)
Expand All @@ -42,8 +42,7 @@ libraryDependencies ++= Seq(
"org.iq80.leveldb" % "leveldb" % "0.12",

("org.scorexfoundation" %% "scorex-core" % scorexVersion).exclude("ch.qos.logback", "logback-classic"),

"org.typelevel" %% "cats-free" % "1.6.0",

"javax.xml.bind" % "jaxb-api" % "2.4.0-b180830.0359",
"com.iheart" %% "ficus" % "1.4.7",
"ch.qos.logback" % "logback-classic" % "1.2.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,13 @@ import org.ergoplatform.ErgoBoxAssets
* @param box - Underlying Ergo box
* @param scans - Identifiers of scans the box refers to
*/
final case class TrackedBox(creationTxId: ModifierId,
creationOutIndex: Short,
inclusionHeightOpt: Option[Int],
spendingTxIdOpt: Option[ModifierId],
spendingHeightOpt: Option[Int],
box: ErgoBox,
scans: Set[ScanId]) extends ErgoBoxAssets {

case class TrackedBox(creationTxId: ModifierId,
creationOutIndex: Short,
inclusionHeightOpt: Option[Int],
spendingTxIdOpt: Option[ModifierId],
spendingHeightOpt: Option[Int],
box: ErgoBox,
scans: Set[ScanId]) extends ErgoBoxAssets {

/**
* Whether the box is spent or not
Expand Down Expand Up @@ -86,6 +85,17 @@ object TrackedBox {
box: ErgoBox, appStatuses: Set[ScanId]): TrackedBox =
apply(creationTx.id, creationOutIndex, creationHeight, None, None, box, appStatuses)

/**
* Creates unspent box with given inclusion height and scans the box is associated with
* @param box
* @param inclusionHeight
* @param scans
* @return
*/
def apply(box: ErgoBox, inclusionHeight: Int, scans: Set[ScanId]): TrackedBox = {
new TrackedBox(box.transactionId, box.index, Some(inclusionHeight), None, None, box, scans)
}

}

object TrackedBoxSerializer extends ErgoWalletSerializer[TrackedBox] {
Expand Down
66 changes: 61 additions & 5 deletions src/main/resources/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,20 @@ components:
boxId:
$ref: '#/components/schemas/TransactionBoxId'

ScanIdsBox:
description: Ergo box with associated scans (their respective identifiers)
type: object
required:
- scanIds
- box
properties:
scanIds:
type: array
items:
type: integer
box:
$ref: '#/components/schemas/ErgoTransactionOutput'

PaymentRequest:
description: Request for generation of payment transaction to a given address
type: object
Expand Down Expand Up @@ -902,11 +916,6 @@ components:
type: integer
format: int32
example: 8
fee:
description: Optional, default transaction fee from settings will be used if not defined
type: integer
format: int64
example: 1000000
registers:
description: Optional, possible values for registers R7...R9
$ref: '#/components/schemas/Registers'
Expand Down Expand Up @@ -2516,6 +2525,24 @@ paths:
schema:
$ref: '#/components/schemas/ApiError'

/wallet/rescan:
get:
security:
- ApiKeyAuth: [api_key]
summary: Rescan wallet (all the available full blocks)
operationId: walletRescan
tags:
- wallet
responses:
'200':
description: Wallet storage recreated
default:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'

/wallet/status:
get:
security:
Expand Down Expand Up @@ -3579,6 +3606,35 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/ScanIdBoxId'
default:
description: Error
content:
application/json:
schema:
$ref: '#/components/schemas/ApiError'

/scan/addBox:
post:
security:
- ApiKeyAuth: [api_key]
summary: Adds a box to scans, writes box to database if it is not there. You can use scan number 10 to add a box to the wallet.
operationId: addBox
tags:
- scan
- wallet
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/ScanIdsBox'
responses:
'200':
description: It the box is added successfully, then its id is returned
content:
application/json:
schema:
$ref: '#/components/schemas/TransactionId'
default:
description: Error
content:
Expand Down
4 changes: 0 additions & 4 deletions src/main/resources/devnet.conf
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ ergo {
initialDifficultyHex = "0001d4c0"
}
wallet.secretStorage.secretDir = ${ergo.directory}"/wallet/keystore"
bootstrap {
resourceUri = "http://188.166.109.25:5000/bootSettings"
pollDelay = 10s
}
}
scorex {
network {
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/panel/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/static/css/main.f6c8bfb4.chunk.css",
"main.js": "/static/js/main.5a370586.chunk.js",
"main.js.map": "/static/js/main.5a370586.chunk.js.map",
"main.js": "/static/js/main.d2ee9699.chunk.js",
"main.js.map": "/static/js/main.d2ee9699.chunk.js.map",
"runtime-main.js": "/static/js/runtime-main.8fa4c17a.js",
"runtime-main.js.map": "/static/js/runtime-main.8fa4c17a.js.map",
"static/css/2.a94a8b68.chunk.css": "/static/css/2.a94a8b68.chunk.css",
"static/js/2.637d7a90.chunk.js": "/static/js/2.637d7a90.chunk.js",
"static/js/2.637d7a90.chunk.js.map": "/static/js/2.637d7a90.chunk.js.map",
"index.html": "/index.html",
"precache-manifest.d1d7c8d8559118114220728682d484c9.js": "/precache-manifest.d1d7c8d8559118114220728682d484c9.js",
"precache-manifest.c85cf283695a25241e587d74bf1b1e14.js": "/precache-manifest.c85cf283695a25241e587d74bf1b1e14.js",
"service-worker.js": "/service-worker.js",
"static/css/2.a94a8b68.chunk.css.map": "/static/css/2.a94a8b68.chunk.css.map",
"static/css/main.f6c8bfb4.chunk.css.map": "/static/css/main.f6c8bfb4.chunk.css.map",
Expand All @@ -21,6 +21,6 @@
"static/css/2.a94a8b68.chunk.css",
"static/js/2.637d7a90.chunk.js",
"static/css/main.f6c8bfb4.chunk.css",
"static/js/main.5a370586.chunk.js"
"static/js/main.d2ee9699.chunk.js"
]
}
2 changes: 1 addition & 1 deletion src/main/resources/panel/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.svg"/><meta name="viewport" content="minimum-scale=1,initial-scale=1,width=device-width,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Ergo node interface</title><link href="/static/css/2.a94a8b68.chunk.css" rel="stylesheet"><link href="/static/css/main.f6c8bfb4.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><div id="modal-root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],Object.prototype.hasOwnProperty.call(c,t)&&c[t]&&i.push(c[t][0]),c[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return p.push.apply(p,u||[]),a()}function a(){for(var e,r=0;r<p.length;r++){for(var t=p[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==c[u]&&(n=!1)}n&&(p.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},c={1:0},p=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=this["webpackJsonpergo-node-interface"]=this["webpackJsonpergo-node-interface"]||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/2.637d7a90.chunk.js"></script><script src="/static/js/main.5a370586.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="shortcut icon" href="/favicon.svg"/><meta name="viewport" content="minimum-scale=1,initial-scale=1,width=device-width,shrink-to-fit=no"/><meta name="theme-color" content="#000000"/><link rel="manifest" href="/manifest.json"/><title>Ergo node interface</title><link href="/static/css/2.a94a8b68.chunk.css" rel="stylesheet"><link href="/static/css/main.f6c8bfb4.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><div id="modal-root"></div><script>!function(l){function e(e){for(var r,t,n=e[0],o=e[1],u=e[2],f=0,i=[];f<n.length;f++)t=n[f],Object.prototype.hasOwnProperty.call(c,t)&&c[t]&&i.push(c[t][0]),c[t]=0;for(r in o)Object.prototype.hasOwnProperty.call(o,r)&&(l[r]=o[r]);for(s&&s(e);i.length;)i.shift()();return p.push.apply(p,u||[]),a()}function a(){for(var e,r=0;r<p.length;r++){for(var t=p[r],n=!0,o=1;o<t.length;o++){var u=t[o];0!==c[u]&&(n=!1)}n&&(p.splice(r--,1),e=f(f.s=t[0]))}return e}var t={},c={1:0},p=[];function f(e){if(t[e])return t[e].exports;var r=t[e]={i:e,l:!1,exports:{}};return l[e].call(r.exports,r,r.exports,f),r.l=!0,r.exports}f.m=l,f.c=t,f.d=function(e,r,t){f.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},f.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},f.t=function(r,e){if(1&e&&(r=f(r)),8&e)return r;if(4&e&&"object"==typeof r&&r&&r.__esModule)return r;var t=Object.create(null);if(f.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:r}),2&e&&"string"!=typeof r)for(var n in r)f.d(t,n,function(e){return r[e]}.bind(null,n));return t},f.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(r,"a",r),r},f.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},f.p="/";var r=this["webpackJsonpergo-node-interface"]=this["webpackJsonpergo-node-interface"]||[],n=r.push.bind(r);r.push=e,r=r.slice();for(var o=0;o<r.length;o++)e(r[o]);var s=n;a()}([])</script><script src="/static/js/2.637d7a90.chunk.js"></script><script src="/static/js/main.d2ee9699.chunk.js"></script></body></html>
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "fa20f17e2c568ac2ce5ac36c4e17de30",
"revision": "886d9d7a31acaa442ac06d534acf79c5",
"url": "/index.html"
},
{
"revision": "fd15a7f2865df4340d30",
"url": "/static/css/2.a94a8b68.chunk.css"
},
{
"revision": "cd542706258c59b4adcb",
"revision": "dddfb9512708699add4a",
"url": "/static/css/main.f6c8bfb4.chunk.css"
},
{
"revision": "fd15a7f2865df4340d30",
"url": "/static/js/2.637d7a90.chunk.js"
},
{
"revision": "cd542706258c59b4adcb",
"url": "/static/js/main.5a370586.chunk.js"
"revision": "dddfb9512708699add4a",
"url": "/static/js/main.d2ee9699.chunk.js"
},
{
"revision": "c51552afbc3cf987b481",
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/panel/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");

importScripts(
"/precache-manifest.d1d7c8d8559118114220728682d484c9.js"
"/precache-manifest.c85cf283695a25241e587d74bf1b1e14.js"
);

self.addEventListener('message', (event) => {
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ scorex {
deliveryTimeout = 10s

# Max number of delivery checks. Stop expecting modifier (and penalize peer) if it was not delivered on time
maxDeliveryChecks = 40
maxDeliveryChecks = 2

############
# Timeouts #
Expand Down
59 changes: 0 additions & 59 deletions src/main/scala/org/ergoplatform/BootstrapController.scala

This file was deleted.

16 changes: 0 additions & 16 deletions src/main/scala/org/ergoplatform/ErgoApp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,6 @@ class ErgoApp(args: Args) extends ScorexLogging {
implicit private val actorSystem: ActorSystem = ActorSystem(settings.network.agentName)
implicit private val executionContext: ExecutionContext = actorSystem.dispatcher

ergoSettings = ergoSettings.bootstrapSettingsOpt match {
case Some(bs) if isEmptyState =>
log.info("Entering coordinated network bootstrap procedure ..")
val (npmProof, genesisDigest) =
new BootstrapController(bs).waitForBootSettings()
log.info("Boot settings received. Starting the node ..")
ergoSettings.copy(
chainSettings = ergoSettings.chainSettings.copy(
noPremineProof = npmProof,
genesisStateDigestHex = genesisDigest
)
)
case _ =>
ergoSettings
}

private val features: Seq[PeerFeature] = Seq(ModeFeature(ergoSettings.nodeSettings))

private val timeProvider = new NetworkTimeProvider(settings.ntp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import org.ergoplatform.settings.ErgoSettings
import scorex.core.api.http.ApiResponse
import scorex.core.settings.RESTApiSettings

final case class EmissionApiRoute(ergoSettings: ErgoSettings)
(implicit val context: ActorRefFactory) extends ErgoBaseApiRoute {
case class EmissionApiRoute(ergoSettings: ErgoSettings)
(implicit val context: ActorRefFactory) extends ErgoBaseApiRoute {

import EmissionApiRoute._

Expand Down
11 changes: 9 additions & 2 deletions src/main/scala/org/ergoplatform/http/api/ScanApiRoute.scala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ case class ScanApiRoute(readersHolder: ActorRef, ergoSettings: ErgoSettings)
deregisterR ~
listScansR ~
unspentR ~
stopTrackingR
stopTrackingR ~
addBoxR
}

def registerR: Route = (path("register") & post & entity(as[ScanRequest])) { request =>
Expand All @@ -55,7 +56,6 @@ case class ScanApiRoute(readersHolder: ActorRef, ergoSettings: ErgoSettings)
}
}

//todo: paging?
def listScansR: Route = (path("listAll") & get) {
withWallet(_.readScans().map(_.apps))
}
Expand All @@ -74,4 +74,11 @@ case class ScanApiRoute(readersHolder: ActorRef, ergoSettings: ErgoSettings)
}
}

def addBoxR: Route = (path("addBox") & post & entity(as[BoxWithScanIds])) { scanIdsBox =>
withWalletOp(_.addBox(scanIdsBox.box, scanIdsBox.scanIds).map(_.status)) {
case Failure(e) => BadRequest(s"Bad request ($scanIdsBox): ${Option(e.getMessage).getOrElse(e.toString)}")
case Success(_) => ApiResponse(scanIdsBox.box.id)
}
}

}
15 changes: 7 additions & 8 deletions src/main/scala/org/ergoplatform/http/api/ScanEntities.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.ergoplatform.http.api

import io.circe.{Decoder, HCursor}
import org.ergoplatform.ErgoBox.BoxId
import org.ergoplatform.JsonCodecs
import org.ergoplatform.{ErgoBox, JsonCodecs}
import org.ergoplatform.wallet.Constants.ScanId

/**
Expand Down Expand Up @@ -32,17 +32,16 @@ object ScanEntities {

}

case class ScanIdBox(scanId: ScanId, boxBytes: Array[Byte])

object ScanIdBox extends JsonCodecs {
case class BoxWithScanIds(box: ErgoBox, scanIds: Set[ScanId])

implicit val scanIdBoxDecoder: Decoder[ScanIdBox] = { c: HCursor =>
object BoxWithScanIds extends JsonCodecs {
implicit val scanIdsBoxDecoder: Decoder[BoxWithScanIds] = { c: HCursor =>
for {
scanId <- ScanId @@ c.downField("scanId").as[Short]
boxBytes <- c.downField("boxBytes").as[Array[Byte]]
} yield ScanIdBox(scanId, boxBytes)
box <- c.downField("box").as[ErgoBox]
scanIds <- ScanId @@ c.downField("scanIds").as[Set[Short]]
} yield BoxWithScanIds(box, scanIds)
}

}

}
Loading

0 comments on commit 0c18522

Please sign in to comment.