Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lnd config to sideload headers. #8580

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
67 changes: 67 additions & 0 deletions itest/lnd_test.go
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set up this test so that it does not connect to the miner so that I can be sure that blockheaders are fed through the sideload source. The problem with that is that cfheaders would not be updated and lnd waits for the chain to be synced before starting up fully so this test would not work.

I do not know if there are any suggestions around this.

Or maybe I would continue with this when I include cfheaders sideloading in the neutrino side (which I would do after I get feedback and clarification on the latest iteration)

CC: @Roasbeef

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe I would continue with this when I include cfheaders sideloading in the neutrino side (which I would do after I get feedback and clarification on the latest iteration)

Yeah we want both the regular block headers and cfheaders.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

"github.com/btcsuite/btcd/chaincfg"
"github.com/btcsuite/btcd/integration/rpctest"
"github.com/lightninglabs/neutrino/sideload"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/lnrpc/chainrpc"
"github.com/lightningnetwork/lnd/lntest"
"github.com/lightningnetwork/lnd/lntest/node"
"github.com/lightningnetwork/lnd/lntest/port"
Expand Down Expand Up @@ -102,6 +104,14 @@
)
defer harnessTest.Stop()

if harnessTest.IsNeutrinoSideloadTest() {
t.Run("test neutrino sideload", func(t *testing.T) {
testNeutrinoSideload(t, harnessTest)
})

return
}

// Setup standby nodes, Alice and Bob, which will be alive and shared
// among all the test cases.
harnessTest.SetupStandbyNodes()
Expand Down Expand Up @@ -156,6 +166,63 @@
"cases, end height: %d\n", trancheIndex, len(testCases), height)
}

func testNeutrinoSideload(t *testing.T, harness *lntest.HarnessTest) {
if !harness.IsNeutrinoSideloadTest() {
return
}

testCfg := &sideload.TestCfg{
StartHeight: 0,
EndHeight: 1000,
Net: harnessNetParams.Net,
DataType: sideload.BlockHeaders,
}

headers := lntest.GenerateBlockHeaderBytes(
uint32(testCfg.EndHeight-testCfg.StartHeight),
harness.Miner.Harness, t,
)

reader := sideload.GenerateEncodedBinaryReader(
t, testCfg, headers,
)

tempFile, err := os.CreateTemp("", "neutrino")
require.NoError(t, err)

defer func() {
err = tempFile.Close()
require.NoError(t, err)

err = os.Remove(tempFile.Name())
require.NoError(t, err)
}()

_, err = io.Copy(tempFile, reader)
require.NoError(t, err)

_, err = reader.Seek(0, io.SeekStart)
require.NoError(t, err)

extraArgs := []string{
"--neutrino.sideload.enable",
"--neutrino.sideload.sourceType=binary",
"--neutrino.sideload.sourcePath=" + tempFile.Name(),
"--neutrino.sideload.skipVerify",
}

obiNode := harness.NewNode("obi", extraArgs)
d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind-notxindex, backend="bitcoind notxindex")

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind, backend=bitcoind)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind-etcd, backend=bitcoind dbbackend=etcd)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind-postgres, backend=bitcoind dbbackend=postgres)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind-postgres-nativesql, backend=bitcoind dbbackend=postgres nativesql=true)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run macOS itest

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind-rpcpolling, backend="bitcoind rpcpolling")

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind-sqlite, backend=bitcoind dbbackend=sqlite)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (bitcoind-sqlite-nativesql, backend=bitcoind dbbackend=sqlite nativesql=true)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (btcd, backend=btcd)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run ubuntu itests (neutrino, backend=neutrino)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run windows itest

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / check commits

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run unit tests (btcd unit-cover)

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run unit tests (unit tags="kvdb_sqlite")

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run unit tests (unit tags="kvdb_postgres")

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run unit tests (unit tags="kvdb_etcd")

undefined: d

Check failure on line 215 in itest/lnd_test.go

View workflow job for this annotation

GitHub Actions / run unit tests (btcd unit-race)

undefined: d

request := chainrpc.GetBlockHashRequest{
BlockHeight: int64(testCfg.EndHeight),
}

resp := obiNode.RPC.GetBlockHash(&request)

require.NotZero(t, len(resp.BlockHash))
}

// getTestCaseSplitTranche returns the sub slice of the test cases that should
// be run as the current split tranche as well as the index and slice offset of
// the tranche.
Expand Down
Loading