From 57e39bea23992229637fddf2a32d1f74abda479a Mon Sep 17 00:00:00 2001 From: Alexander Chepurnoy Date: Sun, 18 Aug 2024 23:05:40 +0300 Subject: [PATCH] Header.bytes removed --- core/shared/src/main/scala/sigma/SigmaDsl.scala | 2 -- .../scala/sigma/reflection/ReflectionData.scala | 3 --- .../src/main/scala/sigma/data/CHeader.scala | 2 -- .../TestingInterpreterSpecification.scala | 7 ++----- .../sigmastate/utxo/BasicOpsSpecification.scala | 16 +++++++--------- 5 files changed, 9 insertions(+), 21 deletions(-) diff --git a/core/shared/src/main/scala/sigma/SigmaDsl.scala b/core/shared/src/main/scala/sigma/SigmaDsl.scala index 42d8df1587..c8bf9aabaf 100644 --- a/core/shared/src/main/scala/sigma/SigmaDsl.scala +++ b/core/shared/src/main/scala/sigma/SigmaDsl.scala @@ -466,8 +466,6 @@ trait Header { def serializeWithoutPoW: Coll[Byte] def checkPow: Boolean - - def bytes: Coll[Byte] } /** Runtime representation of Context ErgoTree type. diff --git a/core/shared/src/main/scala/sigma/reflection/ReflectionData.scala b/core/shared/src/main/scala/sigma/reflection/ReflectionData.scala index 174a631210..795d0bb8de 100644 --- a/core/shared/src/main/scala/sigma/reflection/ReflectionData.scala +++ b/core/shared/src/main/scala/sigma/reflection/ReflectionData.scala @@ -349,9 +349,6 @@ object ReflectionData { }, mkMethod(clazz, "checkPow", Array[Class[_]]()) { (obj, _) => obj.asInstanceOf[Header].checkPow - }, - mkMethod(clazz, "bytes", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].bytes } ) ) diff --git a/data/shared/src/main/scala/sigma/data/CHeader.scala b/data/shared/src/main/scala/sigma/data/CHeader.scala index 1a0d5b37ed..e579f05844 100644 --- a/data/shared/src/main/scala/sigma/data/CHeader.scala +++ b/data/shared/src/main/scala/sigma/data/CHeader.scala @@ -81,8 +81,6 @@ case class CHeader(ergoHeader: ErgoHeader) extends Header with WrapperOf[ErgoHea } } - override def bytes: Coll[Byte] = Colls.fromArray(ergoHeader.bytes) - } object CHeader { diff --git a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala index 28a4d792aa..a783eab745 100644 --- a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala @@ -13,12 +13,9 @@ import org.scalatest.BeforeAndAfterAll import scorex.util.encode.{Base16, Base58} import sigma.Colls import sigma.VersionContext.V6SoftForkVersion -import sigma.data.{CAND, CAvlTree, ProveDlog, SigmaBoolean, TrivialProp} +import sigma.data.{CAND, CAvlTree, CHeader, ProveDlog, SigmaBoolean, TrivialProp} import sigma.interpreter.ContextExtension -import scorex.util.encode.Base58 import sigma.VersionContext -import sigma.crypto.CryptoConstants -import sigma.data.{AvlTreeData, CAND, ProveDlog, SigmaBoolean, TrivialProp} import sigma.util.Extensions.IntOps import sigmastate.helpers.{CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestInterpreter, ErgoLikeTestProvingInterpreter} import sigmastate.helpers.TestingHelpers._ @@ -497,7 +494,7 @@ class TestingInterpreterSpecification extends CompilerTestingCommons property("bytes") { - val headerBytes = Base16.encode(contextHeader.bytes.toArray) + val headerBytes = Base16.encode(contextHeader.asInstanceOf[CHeader].ergoHeader.bytes) // checking hash of bytes(id) against known value val source = s""" { diff --git a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala index f8c0bdbadb..ba5ff42f7d 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala @@ -7,15 +7,14 @@ import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert} import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.ByteArrayBuilder import scorex.util.encode.Base16 -import scorex.util.serialization.{VLQByteBufferReader, VLQByteBufferWriter} -import scorex.utils.{Ints, Longs, Shorts} -import sigma.{BigInt, Colls, SigmaTestingData} -import scorex.util.encode.Base16 +import scorex.util.serialization.VLQByteBufferWriter +import scorex.utils.Longs +import sigma.{Colls, SigmaTestingData} import sigma.Extensions.ArrayOps import sigma.VersionContext.V6SoftForkVersion import sigma.ast.SCollection.SByteArray import sigma.ast.SType.AnyOps -import sigma.data.{AvlTreeData, AvlTreeFlags, CAND, CAnyValue, CSigmaDslBuilder, CSigmaProp} +import sigma.data.{AvlTreeData, AvlTreeFlags, CAND, CAnyValue, CHeader, CSigmaDslBuilder, CSigmaProp} import sigma.util.StringUtil._ import sigma.ast._ import sigma.ast.syntax._ @@ -29,10 +28,9 @@ import sigmastate.interpreter.Interpreter._ import sigma.ast.Apply import sigma.eval.EvalSettings import sigma.exceptions.InvalidType -import sigma.serialization.{ConstantStore, DataSerializer, ErgoTreeSerializer, SigmaByteReader, SigmaByteWriter, ValueSerializer} +import sigma.serialization.{DataSerializer, ErgoTreeSerializer, SigmaByteWriter} import sigma.util.Extensions import sigmastate.utils.Helpers -import sigma.serialization.ErgoTreeSerializer import sigmastate.utils.Helpers._ import java.math.BigInteger @@ -420,7 +418,7 @@ class BasicOpsSpecification extends CompilerTestingCommons property("deserializeTo - header") { val td = new SigmaTestingData {} val h1 = td.TestData.h1 - val headerBytes = h1.bytes + val headerBytes = h1.asInstanceOf[CHeader].ergoHeader.bytes val headerStateBytes = AvlTreeData.serializer.toBytes(Extensions.CoreAvlTreeOps(h1.stateRoot).toAvlTreeData) val customExt = Seq(21.toByte -> ByteArrayConstant(headerBytes), 22.toByte -> ByteArrayConstant(headerStateBytes)) @@ -447,7 +445,7 @@ class BasicOpsSpecification extends CompilerTestingCommons property("deserializeTo - header option") { val td = new SigmaTestingData {} - val h1 = td.TestData.h1 + val h1 = td.TestData.h1.asInstanceOf[CHeader].ergoHeader val headerBytes = Colls.fromArray(Array(1.toByte) ++ h1.bytes.toArray) val customExt = Seq(21.toByte -> ByteArrayConstant(headerBytes))