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

LoPri: Callers for UKM hooks that use/return Bytes or Int256 #133

Open
virgil-serbanuta opened this issue Oct 2, 2024 · 0 comments
Open
Labels

Comments

@virgil-serbanuta
Copy link
Member

virgil-serbanuta commented Oct 2, 2024

Needs #123 and #135

The hooks are described in the UKM-HOOKS module here: https://pi-squared-workspace.slack.com/archives/C07B7RED0GG/p1727373614200429 (hte latest version available when this was written)

Should take something like this:

#[ethereum::hooks]
Trait Hooks {
        ...
	#[hook("CallData")]
        Fn CallDataRust(self) -> Bytes;
        ...
}

change the function so that it looks similar to this:

        Fn CallData(self) -> Bytes {
	        callData()
        }

where the callData thing is declared and evaluated in K like this:

syntax Expression ::= callData()
rule callData() => bytesStructFromKBytes(wrappedBytes(CallData()))

(See #135 for the implementation of bytesStructFromKBytes)
We handle hooks that return Int256 in a similar way, except that we use int256FromInt.

For things that use Bytes as arguments (all of them return ether K or MessageResult so they are not part of this issue) or In256 as arguments, we will do the following:

We will take something like this:

#[ethereum::hooks]
Trait Hooks {
        ...
	#[hook("Log1")]
        Fn Log1Rust(self, topic:Int256, data: Bytes);
        ...
}

change the function so that it looks similar to this:

        Fn Log1Rust(self, topic:Int256, data:Bytes) {
	        log1(topic, data);
        }

where the log1 thing is declared and evaluated in K like this:

syntax Expression ::= log1(Expression, Expression)  [seqstrict]
rule log1(V1:PtrValue, V2:PtrValue) => log1a(int256ToInt(V1 . x1, V1 . x2, , V1 . x3 , V1 . x2), bytesStructToKBytes(V2 . bytes_id))
syntax Expression ::= #log1(Expression, Expression)  [seqstrict]
rule #log1(wrappedInt(I:Int), wrappedBytes(B:Bytes)) => Log1(I, B)

(See #135 for the implementation of bytesStructToKBytes and #127 for int256ToInt)

@virgil-serbanuta virgil-serbanuta changed the title Callers for UKM hooks that use/return Bytes Callers for UKM hooks that use/return Bytes or Int256 Oct 2, 2024
@virgil-serbanuta virgil-serbanuta changed the title Callers for UKM hooks that use/return Bytes or Int256 LoPri: Callers for UKM hooks that use/return Bytes or Int256 Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant