Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/aws/aws-sdk-go-v2 v1.41.1
github.com/aws/aws-sdk-go-v2/config v1.32.8
github.com/aws/aws-sdk-go-v2/service/s3 v1.96.0
github.com/bitcoin-sv/bdk/module/gobdk v1.2.0
github.com/bitcoin-sv/bdk/module/gobdk v1.2.1
github.com/bsv-blockchain/go-bt/v2 v2.6.0
github.com/bsv-blockchain/go-chaincfg v1.5.3
github.com/bsv-blockchain/go-sdk v1.2.18
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24
github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bitcoin-sv/bdk/module/gobdk v1.2.0 h1:MpaiuaQJwyqMwn5+2cANRqKJYZIFzTqbvMg8r8TjTPg=
github.com/bitcoin-sv/bdk/module/gobdk v1.2.0/go.mod h1:6maRlx9FmnAD5vxzSrjOQRyZUV39nbVr/4Tx7hlPlAU=
github.com/bitcoin-sv/bdk/module/gobdk v1.2.1 h1:6bWMgYUdT0wUoiUBliuWRExRPtc28dlUIJ6QxHwqIJc=
github.com/bitcoin-sv/bdk/module/gobdk v1.2.1/go.mod h1:6maRlx9FmnAD5vxzSrjOQRyZUV39nbVr/4Tx7hlPlAU=
github.com/bitcoinschema/go-bitcoin v0.3.20 h1:jWKT7ePYm4dPaIR2aIAVL8BwdsYtuG/4B87l1+KZyWs=
github.com/bitcoinschema/go-bitcoin v0.3.20/go.mod h1:HyyMGUTtGE1qOgFJzCmvgsf3y55IfxJ+qLbwRm4Ski4=
github.com/bitcoinsv/bsvd v0.0.0-20190609155523-4c29707f7173 h1:2yTIV9u7H0BhRDGXH5xrAwAz7XibWJtX2dNezMeNsUo=
Expand Down
15 changes: 1 addition & 14 deletions services/validator/BENCHMARK_RESULTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,7 @@ Full validation includes all checks: ratio validation, script standardness, conf

**Key Finding**: Performance scales linearly with the number of inputs. Even large consolidations (1000 inputs) complete in under 0.4ms.

### 3. Script Validation (`isStandardInputScript`)

Performance of push-only script validation:

| Script Type | Time per Operation |
|-------------|-------------------|
| Empty script | 4.356 ns |
| Standard P2PKH unlock | 422.9 ns |
| Complex push-only (10 pushes) | 861.8 ns |
| Non-standard with ops | 177.6 ns |

**Key Finding**: Script validation is efficient, with typical P2PKH scripts validated in ~423ns.

### 4. Fee Validation Impact Comparison
### 3. Fee Validation Impact Comparison

Comparison of fee validation with and without consolidation checks:

Expand Down
871 changes: 686 additions & 185 deletions services/validator/TxValidator.go

Large diffs are not rendered by default.

70 changes: 21 additions & 49 deletions services/validator/TxValidator_benchmark_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,27 @@ import (
"github.com/bsv-blockchain/teranode/ulogger"
)

// createP2PKHUnlockScript creates a typical P2PKH unlocking script (signature + pubkey)
func createP2PKHUnlockScript() *bscript.Script {
// Typical P2PKH unlock: <sig> <pubkey>
// Signature is ~71 bytes, pubkey is 33 bytes (compressed)
script := bscript.Script{}

// Push signature (71 bytes)
script = append(script, 0x47) // Push 71 bytes
for i := 0; i < 71; i++ {
script = append(script, 0xaa)
}

// Push pubkey (33 bytes)
script = append(script, 0x21) // Push 33 bytes
for i := 0; i < 33; i++ {
script = append(script, 0xbb)
}

return &script
}

// BenchmarkIsConsolidationTxForFees measures the performance of the simplified consolidation check
func BenchmarkIsConsolidationTxForFees(b *testing.B) {
policy := settings.NewPolicySettings()
Expand Down Expand Up @@ -105,55 +126,6 @@ func BenchmarkIsConsolidationTxFull(b *testing.B) {
}
}

// BenchmarkIsStandardInputScript measures the performance of script validation
func BenchmarkIsStandardInputScript(b *testing.B) {
uahfHeight := uint32(478559)
postUAHFHeight := uint32(500000)

benchmarks := []struct {
name string
script *bscript.Script
}{
{
name: "empty_script",
script: &bscript.Script{},
},
{
name: "standard_p2pkh_unlock",
script: createP2PKHUnlockScript(),
},
{
name: "complex_push_only",
script: func() *bscript.Script {
s := &bscript.Script{}
// Multiple push operations
for i := 0; i < 10; i++ {
*s = append(*s, 0x14) // OP_DATA_20
*s = append(*s, make([]byte, 20)...) // 20 bytes of data
}
return s
}(),
},
{
name: "non_standard_with_ops",
script: &bscript.Script{
0x76, // OP_DUP
0xa9, // OP_HASH160
0x14, // OP_DATA_20
},
},
}

for _, bm := range benchmarks {
b.Run(bm.name, func(b *testing.B) {
b.ResetTimer()
for i := 0; i < b.N; i++ {
_ = isStandardInputScript(bm.script, postUAHFHeight, uahfHeight)
}
})
}
}

// BenchmarkConsolidationValidationImpact compares validation with and without consolidation checks
func BenchmarkConsolidationValidationImpact(b *testing.B) {
policy := settings.NewPolicySettings()
Expand Down
256 changes: 0 additions & 256 deletions services/validator/TxValidator_consolidation_nonstandard_test.go

This file was deleted.

Loading
Loading