Skip to content

Commit

Permalink
Initial backend updates to conform to new function signatures in core
Browse files Browse the repository at this point in the history
  • Loading branch information
Lazy Nina committed Dec 4, 2023
1 parent ea9c5d5 commit a246099
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 13 deletions.
14 changes: 8 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ COPY backend/countries countries
COPY backend/main.go .

# include core src
COPY core/bls ../core/bls
COPY core/cmd ../core/cmd
COPY core/desohash ../core/desohash
COPY core/lib ../core/lib
COPY core/migrate ../core/migrate
COPY core/scripts ../core/scripts
COPY core/bls ../core/bls
COPY core/cmd ../core/cmd
COPY core/collections ../core/collections
COPY core/consensus ../core/consensus
COPY core/desohash ../core/desohash
COPY core/lib ../core/lib
COPY core/migrate ../core/migrate
COPY core/scripts ../core/scripts

RUN ../core/scripts/install-relic.sh

Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ require (
github.com/deso-protocol/go-merkle-tree v1.0.0 // indirect
github.com/dgraph-io/ristretto v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/ethereum/go-ethereum v1.9.25 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dvyukov/go-fuzz v0.0.0-20200318091601-be3528f3a813/go.mod h1:11Gm+ccJnvAhCNLlf5+cS9KjtbaD5I5zaZpFMsTHWTw=
github.com/edsrzf/mmap-go v0.0.0-20160512033002-935e0e8a636c/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
Expand Down
4 changes: 2 additions & 2 deletions routes/admin_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,13 @@ func (fes *APIServer) _handleNodeControlGetInfo(
{
desoNodeStatus.LatestHeaderHeight = desoHeaderTip.Height
desoNodeStatus.LatestHeaderHash = hex.EncodeToString(desoHeaderTip.Hash[:])
desoNodeStatus.LatestHeaderTstampSecs = uint32(desoHeaderTip.Header.TstampSecs)
desoNodeStatus.LatestHeaderTstampSecs = uint32(desoHeaderTip.Header.GetTstampSecs())
}
// Main block chain fields
{
desoNodeStatus.LatestBlockHeight = desoBlockTip.Height
desoNodeStatus.LatestBlockHash = hex.EncodeToString(desoBlockTip.Hash[:])
desoNodeStatus.LatestBlockTstampSecs = uint32(desoBlockTip.Header.TstampSecs)
desoNodeStatus.LatestBlockTstampSecs = uint32(desoBlockTip.Header.GetTstampSecs())
}
if fes.TXIndex != nil {
// TxIndex status
Expand Down
4 changes: 2 additions & 2 deletions routes/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func _headerToResponse(header *lib.MsgDeSoHeader, hash string) *HeaderResponse {
Version: header.Version,
PrevBlockHashHex: header.PrevBlockHash.String(),
TransactionMerkleRootHex: header.TransactionMerkleRoot.String(),
TstampSecs: header.TstampSecs,
TstampSecs: header.GetTstampSecs(),
Height: header.Height,
Nonce: header.Nonce,
ExtraNonce: header.ExtraNonce,
Expand Down Expand Up @@ -666,7 +666,7 @@ func APITransactionToResponse(
if block != nil && block.Header != nil {
ret.BlockInfo = &TransactionBlockInfo{
Height: block.Header.Height,
TimestampSecs: block.Header.TstampSecs,
TimestampSecs: block.Header.GetTstampSecs(),
}
}

Expand Down
4 changes: 2 additions & 2 deletions routes/exchange_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func NewLowDifficultyBlockchainWithParams(t *testing.T, params *lib.DeSoParams)
Version: 0,
PrevBlockHash: lib.MustDecodeHexBlockHash("0000000000000000000000000000000000000000000000000000000000000000"),
TransactionMerkleRoot: lib.MustDecodeHexBlockHash("097158f0d27e6d10565c4dc696c784652c3380e0ff8382d3599a4d18b782e965"),
TstampSecs: uint64(1560735050),
Height: uint64(0),
Nonce: uint64(0),
// No ExtraNonce is set in the genesis block
Expand All @@ -120,6 +119,7 @@ func NewLowDifficultyBlockchainWithParams(t *testing.T, params *lib.DeSoParams)
},
},
}
paramsCopy.GenesisBlock.Header.SetTstampSecs(uint64(1560735050))
paramsCopy.MinDifficultyTargetHex = "999999948931e5874cf66a74c0fda790dd8c7458243d400324511a4c71f54faa"
paramsCopy.MinChainWorkHex = "0000000000000000000000000000000000000000000000000000000000000000"
paramsCopy.MiningIterationsPerCycle = 500
Expand Down Expand Up @@ -157,7 +157,7 @@ func NewTestMiner(t *testing.T, chain *lib.Blockchain, params *lib.DeSoParams, i
mempool := lib.NewDeSoMempool(
chain, 0, /* rateLimitFeeRateNanosPerKB */
0 /* minFeeRateNanosPerKB */, "", true,
"" /*dataDir*/, "")
"" /*dataDir*/, "", true)
minerPubKeys := []string{}
if isSender {
minerPubKeys = append(minerPubKeys, senderPkString)
Expand Down
2 changes: 1 addition & 1 deletion routes/miner.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ func (fes *APIServer) SubmitBlock(ww http.ResponseWriter, req *http.Request) {
// TODO: Signature checking slows things down because it acquires the ChainLock.
// The optimal solution is to check signatures in a way that doesn't acquire the
// ChainLock, which is what Bitcoin Core does.
isMainChain, isOrphan, err := fes.blockchain.ProcessBlock(
isMainChain, isOrphan, _, err := fes.blockchain.ProcessBlock(
blockFound, true /*verifySignatures*/)
glog.V(1).Infof("Called ProcessBlock: isMainChain=(%v), isOrphan=(%v), err=(%v)",
isMainChain, isOrphan, err)
Expand Down
1 change: 1 addition & 0 deletions routes/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -3953,6 +3953,7 @@ func (fes *APIServer) simulateSubmitTransaction(utxoView *lib.UtxoView, txn *lib
txn.Hash(),
0,
bestHeight,
0,
false,
false,
)
Expand Down
4 changes: 4 additions & 0 deletions test.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ RUN git pull && \
git checkout feature/proof-of-stake && \
git pull origin feature/proof-of-stake # TODO: Revert to `git pull` once core PR is merged.

# Try to checkout to the specified branch. If it fails, checkout main.
RUN (git checkout ${BRANCH_NAME} && git pull origin ${BRANCH_NAME}) || (echo "Branch ${BRANCH_NAME} not found. Falling back to feature/proof-of-stake." && git checkout feature/proof-of-stake)

RUN go mod download

RUN ./scripts/install-relic.sh

WORKDIR /deso/src/backend
Expand Down

0 comments on commit a246099

Please sign in to comment.