Skip to content

Commit 48a9a76

Browse files
committed
debug travis failing cases
1 parent 7fb73f8 commit 48a9a76

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ before_script:
7878
- if [ "${COVERAGE}" != "true" ] && [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ "$TRAVIS_PHP_VERSION" != "nightly" ]; then phpenv config-rm xdebug.ini && echo "xdebug disabled"; fi
7979

8080
script:
81+
- vendor/bin/phpunit --filter 'TaprootTest::testScript#20'
82+
- vendor/bin/phpunit --filter 'TaprootTest::testScript#21'
8183
- travis/run_secp256k1_tests.sh || exit 1
8284
- if [ "$COVERAGE" = "true" ]; then pwd && vendor/bin/phpstan analyse src tests -l 1; fi
8385
- make phpunit-ci || exit 1

src/Script/Interpreter/Interpreter.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,12 @@ private function verifyWitnessProgram(WitnessProgram $witnessProgram, ScriptWitn
295295
}
296296

297297
if ($witnessCount === 0) {
298+
echo "empty witness\n";
298299
return false;
299300
} else if ($witnessCount >= 2 && $scriptWitness->bottom()->getSize() > 0 && ord($scriptWitness->bottom()->getBinary()[0]) === TaprootHasher::TAPROOT_ANNEX_BYTE) {
300301
$annex = $scriptWitness->bottom();
301302
if (($flags & self::VERIFY_DISCOURAGE_UPGRADABLE_ANNEX)) {
303+
echo "uigradable annex\n";
302304
return false;
303305
}
304306
$execContext->setAnnexHash(Hash::sha256($annex));
@@ -311,6 +313,7 @@ private function verifyWitnessProgram(WitnessProgram $witnessProgram, ScriptWitn
311313
// key spend path - doesn't use the interpreter, directly checks signature
312314
$signature = $scriptWitness[count($scriptWitness) - 1];
313315
if (!$checker->checkSigSchnorr($signature, $witnessProgram->getProgram(), SigHash::TAPROOT, $execContext)) {
316+
echo "invalid signature\n";
314317
return false;
315318
}
316319
return true;
@@ -329,11 +332,13 @@ private function verifyWitnessProgram(WitnessProgram $witnessProgram, ScriptWitn
329332
if ($control->getSize() < TAPROOT_CONTROL_BASE_SIZE ||
330333
$control->getSize() > TAPROOT_CONTROL_MAX_SIZE ||
331334
(($control->getSize() - TAPROOT_CONTROL_BASE_SIZE) % TAPROOT_CONTROL_BRANCH_SIZE !== 0)) {
335+
echo "invalid control size\n";
332336
return false;
333337
}
334338

335339
$leafHash = null;
336340
if (!$this->verifyTaprootCommitment($control, $witnessProgram->getProgram(), $scriptPubKey, $leafHash)) {
341+
echo "invalid taproot commitment\n";
337342
return false;
338343
}
339344
$execContext->setTapLeafHash($leafHash);
@@ -344,11 +349,15 @@ private function verifyWitnessProgram(WitnessProgram $witnessProgram, ScriptWitn
344349
}
345350

346351
// return true at this stage, need further work to proceed
347-
return $this->executeWitnessProgram($scriptWitness, new Script($scriptPubKey), SigHash::TAPSCRIPT, $flags, $checker, $execContext);
352+
$ret = $this->executeWitnessProgram($scriptWitness, new Script($scriptPubKey), SigHash::TAPSCRIPT, $flags, $checker, $execContext);
353+
var_dump("witnessExec");
354+
var_dump($ret);
355+
return $ret;
348356
}
349357
}
350358

351359
if ($flags & self::VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM) {
360+
echo "upgradable witness program\n";
352361
return false;
353362
}
354363

@@ -614,9 +623,9 @@ public function evaluate(ScriptInterface $script, Stack $mainStack, int $sigVers
614623
}
615624

616625
$mainStack->push($pushData);
617-
// echo " - [pushed '" . $pushData->getHex() . "']\n";
626+
echo " - [pushed '" . $pushData->getHex() . "']\n";
618627
} elseif ($fExec || (Opcodes::OP_IF <= $opCode && $opCode <= Opcodes::OP_ENDIF)) {
619-
// echo "OPCODE - " . $script->getOpcodes()->getOp($opCode) . "\n";
628+
echo "OPCODE - " . $script->getOpcodes()->getOp($opCode) . "\n";
620629
switch ($opCode) {
621630
case Opcodes::OP_1NEGATE:
622631
case Opcodes::OP_1:
@@ -1248,11 +1257,11 @@ public function evaluate(ScriptInterface $script, Stack $mainStack, int $sigVers
12481257

12491258
return true;
12501259
} catch (ScriptRuntimeException $e) {
1251-
// echo "\n Runtime: " . $e->getMessage() . "\n" . $e->getTraceAsString() . PHP_EOL;
1260+
echo "\n Runtime: " . $e->getMessage() . "\n" . $e->getTraceAsString() . PHP_EOL;
12521261
// Failure due to script tags, can access flag: $e->getFailureFlag()
12531262
return false;
12541263
} catch (\Exception $e) {
1255-
// echo "\n General: " . $e->getMessage() . PHP_EOL . $e->getTraceAsString() . PHP_EOL;
1264+
echo "\n General: " . $e->getMessage() . PHP_EOL . $e->getTraceAsString() . PHP_EOL;
12561265
return false;
12571266
}
12581267
}

0 commit comments

Comments
 (0)