From a12e6b07b250bc42b71bdd341003fe629f6066db Mon Sep 17 00:00:00 2001 From: Jonathan Downing Date: Tue, 30 Jan 2024 14:26:18 +1100 Subject: [PATCH] ETXs can now deploy a contract by sending to the destination contextual zero-address --- core/state_transition.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/state_transition.go b/core/state_transition.go index 90a60d827d..039ff91831 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -316,8 +316,12 @@ func (st *StateTransition) TransitionDb() (*ExecutionResult, error) { msg := st.msg sender := vm.AccountRef(msg.From()) - contractCreation := msg.To() == nil // for ETX contract creation, perhaps we should compare the "to" to the contextual zero-address (only in the ETX case) - + contractCreation := msg.To() == nil + if st.msg.IsETX() { + // for ETX contract creation, we compare the "to" to the contextual zero-address (only in the ETX case) + // the "from" is also set to the contextual zero-address, so it will look like a transaction from the zero-address to itself + contractCreation = msg.To().Equal(common.ZeroAddress(st.evm.ChainConfig().Location)) + } // Check clauses 4-5, subtract intrinsic gas if everything is correct gas, err := IntrinsicGas(st.data, st.msg.AccessList(), contractCreation) if err != nil {