Skip to content

Commit

Permalink
Changed ADHash to natural
Browse files Browse the repository at this point in the history
  • Loading branch information
Soupstraw committed Nov 8, 2024
1 parent d61bd38 commit d6f0fc6
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 21 deletions.
7 changes: 5 additions & 2 deletions scripts/bump-executable-spec.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ chmod 755 -R $EXEC_SPEC_REPO_DIR
pushd $EXEC_SPEC_REPO_DIR

echo "Removing old files.."
FILES_TO_RM=$(git ls-tree -r main --name-only | grep -vE "flake.lock|flake.nix|CHANGELOG.md|.gitignore")
FILES_TO_RM=$(git ls-tree -r master --name-only | grep -vE "flake.lock|flake.nix|CHANGELOG.md|.gitignore")
for f in $FILES_TO_RM; do
rm -rf $f
done
Expand All @@ -44,7 +44,10 @@ if [ $LEDGER_REPO_DIR ]; then
pushd $LEDGER_REPO_DIR
sed -i "s/tag: .*/tag: $EXEC_SPEC_COMMIT/" cabal.project
sed -i "s/--sha256: .*/--sha256: sha256-0000000000000000000000000000000000000000000=/" cabal.project
sed -i "s/[^-]subdir/ --subdir/" cabal.project
sed -i 's/location: .*$/location: https:\/\/github.com\/Soupstraw\/exec-spec-temporary\.git/' cabal.project
#COMMIT_SHA=$(nix run nix-prefetch-git -- https://github.com/Soupstraw/exec-spec-temporary --rev $EXEC_SPEC_COMMIT | jq .hash)
#sed -i "s/--sha256 .*$/--sha256 $COMMIT_SHA/"
popd
echo "Updated cabal.project in cardano-ledger. Replace sha256 with the hash given by 'nix develop'"
fi
echo "Done!"
5 changes: 3 additions & 2 deletions src/Ledger/Certs.lagda
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,8 @@ data _⊢_⇀⦇_,DELEG⦈_ where
DELEG-delegate : let open PParams pp in
∙ (c ∉ dom rwds → d ≡ keyDeposit)
∙ (c ∈ dom rwds → d ≡ 0)
∙ mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪ ❴ nothing ❵
∙ mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪
fromList ( nothing ∷ just abstainRep ∷ just noConfidenceRep ∷ [] )
∙ mkh ∈ mapˢ just (dom pools) ∪ ❴ nothing ❵
────────────────────────────────
⟦ pp , pools , delegatees ⟧ᵈᵉ ⊢
Expand Down Expand Up @@ -429,7 +430,7 @@ data _⊢_⇀⦇_,CERTBASE⦈_ where
refresh = mapPartial getDRepVote (fromList vs)
refreshedDReps = mapValueRestricted (const (e + drepActivity)) dReps refresh
wdrlCreds = mapˢ stake (dom wdrls)
validVoteDelegs = voteDelegs ∣^ mapˢ (credVoter DRep) (dom dReps)
validVoteDelegs = voteDelegs ∣^ (mapˢ (credVoter DRep) (dom dReps) ∪ fromList (noConfidenceRep ∷ abstainRep ∷ []))
in
∙ filter isKeyHash wdrlCreds ⊆ dom voteDelegs
∙ mapˢ (map₁ stake) (wdrls ˢ) ⊆ rewards ˢ
Expand Down
6 changes: 4 additions & 2 deletions src/Ledger/Certs/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ instance
Computational-DELEG .computeProof ⟦ pp , pools , delegatees ⟧ᵈᵉ ⟦ _ , _ , rwds ⟧ᵈ = λ where
(delegate c mv mc d) case ¿ (c ∉ dom rwds d ≡ pp .PParams.keyDeposit)
× (c ∈ dom rwds d ≡ 0)
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪ ❴ nothing ❵
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪
fromList ( nothing ∷ just abstainRep ∷ just noConfidenceRep ∷ [] )
× mc ∈ mapˢ just (dom pools) ∪ ❴ nothing ❵
¿ of λ where
(yes p) success (-, DELEG-delegate p)
Expand All @@ -38,7 +39,8 @@ instance
Computational-DELEG .completeness ⟦ pp , pools , delegatees ⟧ᵈᵉ ⟦ _ , _ , rwds ⟧ᵈ (delegate c mv mc d)
s' (DELEG-delegate p) rewrite dec-yes (¿ (c ∉ dom rwds d ≡ pp .PParams.keyDeposit)
× (c ∈ dom rwds d ≡ 0)
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪ ❴ nothing ❵
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪
fromList ( nothing ∷ just abstainRep ∷ just noConfidenceRep ∷ [] )
× mc ∈ mapˢ just (dom pools) ∪ ❴ nothing ❵
¿) p .proj₂ = refl
Computational-DELEG .completeness ⟦ _ , _ , _ ⟧ᵈᵉ ⟦ _ , _ , rwds ⟧ᵈ (dereg c d) _ (DELEG-dereg p)
Expand Down
10 changes: 8 additions & 2 deletions src/Ledger/Conway/Conformance/Certs.agda
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,13 @@ data _⊢_⇀⦇_,DELEG⦈_ where
DELEG-delegate : let open PParams pp in
∙ (c ∉ dom rwds d ≡ keyDeposit)
∙ (c ∈ dom rwds d ≡ 0)
∙ mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪ ❴ nothing ❵
∙ mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪
fromList
( nothing
∷ just abstainRep
∷ just noConfidenceRep
∷ []
)
∙ mkh ∈ mapˢ just (dom pools) ∪ ❴ nothing ❵
────────────────────────────────
⟦ pp , pools , delegatees ⟧ᵈᵉ ⊢
Expand Down Expand Up @@ -170,7 +176,7 @@ data _⊢_⇀⦇_,CERTBASE⦈_ : CertEnv → CertState → ⊤ → CertState →
refresh = mapPartial getDRepVote (fromList vs)
refreshedDReps = mapValueRestricted (const (e + drepActivity)) dReps refresh
wdrlCreds = mapˢ stake (dom wdrls)
validVoteDelegs = voteDelegs ∣^ mapˢ (credVoter DRep) (dom dReps)
validVoteDelegs = voteDelegs ∣^ (mapˢ (credVoter DRep) (dom dReps) ∪ fromList (noConfidenceRep ∷ abstainRep ∷ []))
in
∙ filterˢ isKeyHash wdrlCreds ⊆ dom voteDelegs
∙ mapˢ (map₁ stake) (wdrls ˢ) ⊆ rewards ˢ
Expand Down
6 changes: 4 additions & 2 deletions src/Ledger/Conway/Conformance/Certs/Properties.agda
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ instance
Computational-DELEG .computeProof ⟦ pp , pools , delegatees ⟧ᵈᵉ ⟦ _ , _ , rwds , dep ⟧ᵈ = λ where
(delegate c mv mc d) case ¿ (c ∉ dom rwds d ≡ pp .PParams.keyDeposit)
× (c ∈ dom rwds d ≡ 0)
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪ ❴ nothing ❵
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪
fromList ( nothing ∷ just abstainRep ∷ just noConfidenceRep ∷ [] )
× mc ∈ mapˢ just (dom pools) ∪ ❴ nothing ❵ ¿ of λ where
(yes p) success (-, DELEG-delegate p )
(no ¬p) failure (genErrors ¬p)
Expand All @@ -34,7 +35,8 @@ instance
Computational-DELEG .completeness ⟦ pp , pools , delegatees ⟧ᵈᵉ ⟦ _ , _ , rwds , dep ⟧ᵈ (delegate c mv mc d)
s' (DELEG-delegate p) rewrite dec-yes (¿ (c ∉ dom rwds d ≡ pp .PParams.keyDeposit)
× (c ∈ dom rwds d ≡ 0)
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪ ❴ nothing ❵
× mv ∈ mapˢ (just ∘ credVoter DRep) delegatees ∪
fromList ( nothing ∷ just abstainRep ∷ just noConfidenceRep ∷ [] )
× mc ∈ mapˢ just (dom pools) ∪ ❴ nothing ❵ ¿) p .proj₂ = refl
Computational-DELEG .completeness ⟦ _ , _ , _ ⟧ᵈᵉ ⟦ _ , _ , rwds , dep ⟧ᵈ (dereg c d) _ (DELEG-dereg p)
rewrite dec-yes (¿ (c , 0) ∈ rwds × (CredentialDeposit c , d) ∈ dep ¿) p .proj₂ = refl
Expand Down
10 changes: 5 additions & 5 deletions src/Ledger/Conway/Foreign/HSLedger/Core.agda
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ instance
Hashable-⊤ = λ where .hash tt 0

module Implementation where
Network =
Network =
SlotsPerEpochᶜ = 100
StabilityWindowᶜ = 10
Quorum = 1
NetworkId = tt
NetworkId = 0 -- Testnet

SKey =
VKey =
Expand All @@ -49,10 +49,10 @@ module Implementation where
sign = _+_
ScriptHash =

Data =
Data =
Dataʰ = mkHashableSet Data
toData : {A : Type} A Data
toData _ = tt
toData _ = 0

PlutusScript =
ExUnits = ℕ × ℕ
Expand Down Expand Up @@ -96,7 +96,7 @@ module Implementation where

TxId =
Ix =
AuxiliaryData =
AuxiliaryData =
DocHash =
tokenAlgebra = coinTokenAlgebra

Expand Down
4 changes: 2 additions & 2 deletions src/Ledger/hs-src/test/UtxowSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ initEnv :: UTxOEnv
initEnv = MkUTxOEnv {ueSlot = 0, uePparams = initParams, ueTreasury = 0}

baseAddr :: Integer -> Addr
baseAddr n = Left BaseAddr{baseNet = (), basePay = KeyHashObj n, baseStake = KeyHashObj n}
baseAddr n = Left BaseAddr{baseNet = 0, basePay = KeyHashObj n, baseStake = KeyHashObj n}

a0 :: Addr
a0 = baseAddr 0
Expand Down Expand Up @@ -106,7 +106,7 @@ bodyFromSimple pp stxb = let s = 5 in MkTxBody
, txdonation = 0
, txup = Nothing
, txADhash = Nothing
, txNetworkId = Just ()
, txNetworkId = Just 0
, curTreasury = Nothing
, collateral = MkHSSet []
, reqSigHash = MkHSSet []
Expand Down
6 changes: 3 additions & 3 deletions src/ScriptVerification/LedgerImplementation.agda
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ instance
Hashable-⊤ = λ where .hash tt 0

module Implementation where
Network =
Network =
SlotsPerEpochᶜ = 100
StabilityWindowᶜ = 10
Quorum = 1
NetworkId = tt
NetworkId = 0

SKey =
VKey =
Expand Down Expand Up @@ -92,7 +92,7 @@ module Implementation where

TxId =
Ix =
AuxiliaryData =
AuxiliaryData =
DocHash =
tokenAlgebra = coinTokenAlgebra

Expand Down
2 changes: 1 addition & 1 deletion src/ScriptVerification/Lib.agda
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ createUTxO : (index : ℕ)
Maybe (D ⊎ DataHash)
TxIn × TxOut
createUTxO index wallet value d = (index , index)
, (inj₁ (record { net = tt ; pay = KeyHashObj wallet ; stake = KeyHashObj wallet })
, (inj₁ (record { net = 0 ; pay = KeyHashObj wallet ; stake = KeyHashObj wallet })
, value , d , nothing)

createInitUtxoState : (wallets : ℕ)
Expand Down

0 comments on commit d6f0fc6

Please sign in to comment.